Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@glimmer/syntax

Package Overview
Dependencies
Maintainers
12
Versions
289
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@glimmer/syntax

  • 0.83.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
272K
decreased by-1.5%
Maintainers
12
Weekly downloads
 
Created

What is @glimmer/syntax?

@glimmer/syntax is a library for parsing, traversing, and transforming Glimmer templates. It provides tools to work with the syntax tree of Glimmer templates, which are used in Ember.js applications.

What are @glimmer/syntax's main functionalities?

Parsing Templates

This feature allows you to parse a Glimmer template string into an Abstract Syntax Tree (AST). The `preprocess` function takes a template string and returns its AST representation.

const { preprocess } = require('@glimmer/syntax');
const template = '<div>{{hello}}</div>';
const ast = preprocess(template);
console.log(ast);

Traversing AST

This feature allows you to traverse the AST of a Glimmer template. The `traverse` function takes an AST and a visitor object, which defines the functions to be called for different node types.

const { traverse } = require('@glimmer/syntax');
const ast = preprocess('<div>{{hello}}</div>');
traverse(ast, {
  MustacheStatement(node) {
    console.log('Found a mustache statement:', node);
  }
});

Transforming AST

This feature allows you to transform the AST of a Glimmer template. You can modify nodes in the AST and then convert it back to a template string using the `print` function.

const { preprocess, print, builders } = require('@glimmer/syntax');
let ast = preprocess('<div>{{hello}}</div>');
traverse(ast, {
  MustacheStatement(node) {
    node.path = builders.path('goodbye');
  }
});
const transformedTemplate = print(ast);
console.log(transformedTemplate);

Other packages similar to @glimmer/syntax

FAQs

Package last updated on 08 Nov 2021

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc