🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

twig-parser

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

twig-parser

This tool transforms a twig template to AST

latest
Source
npmnpm
Version
0.2.2
Version published
Maintainers
1
Created
Source

Twig Parser

This tool transforms a twig template to AST. It uses chevrotain under the hood.

How to use it

import { parse } from 'twig-parser';

const twig = `
  {% set foo = range(0, 3) %}

  {% for i in foo %}
      {{ i }},
  {% endfor %}
`

const { ast, tokens, errors } = parse(twig);

Notes

  • Whitespace trimming is not supported
  • The body of the verbatim tag is parsed as a regular template

FAQs

Package last updated on 06 May 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts