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

ember-template-recast

Package Overview
Dependencies
Maintainers
7
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ember-template-recast

Non-destructive template transformer.

  • 6.1.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
125K
increased by10.69%
Maintainers
7
Weekly downloads
 
Created

What is ember-template-recast?

ember-template-recast is a tool for programmatically modifying Handlebars templates in Ember.js projects. It provides a way to parse, traverse, and transform templates, making it useful for tasks such as codemods, linting, and automated refactoring.

What are ember-template-recast's main functionalities?

Parsing Templates

This feature allows you to parse a Handlebars template string into an Abstract Syntax Tree (AST). The AST can then be traversed and manipulated.

const recast = require('ember-template-recast');
const template = '<div>{{foo}}</div>';
const ast = recast.parse(template);
console.log(ast);

Transforming Templates

This feature allows you to transform a Handlebars template by providing a transformation function. The example changes all instances of `{{foo}}` to `{{bar}}`.

const recast = require('ember-template-recast');
const template = '<div>{{foo}}</div>';
const transform = function(env) {
  let { builders: b } = env.syntax;
  return {
    MustacheStatement(node) {
      if (node.path.original === 'foo') {
        return b.mustache(b.path('bar'));
      }
    }
  };
};
const output = recast.transform(template, transform);
console.log(output);

Printing Templates

This feature allows you to convert an AST back into a Handlebars template string. This is useful after making transformations to the AST.

const recast = require('ember-template-recast');
const template = '<div>{{foo}}</div>';
const ast = recast.parse(template);
const output = recast.print(ast);
console.log(output);

Other packages similar to ember-template-recast

Keywords

FAQs

Package last updated on 10 Dec 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