Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
hbs-ast-to-str
Advanced tools
Converts Handlebars Abstract Syntax Tree (AST) back to template string.
This project converts a Converts Handlebars Abstract Syntax Tree (AST) back to template string with processing( optional).
npm install hbs-ast-to-str
with out any modification options
const {convertAstToString} = require('hbs-ast-to-str');
const ast = {
/* Your Handlebars AST using Handlebars.parse(template_str)*/
};
const template = convertAstToString(ast);
with modification options
const {convertAstToString} = require('hbs-ast-to-str');
const ast = {
/* Your Handlebars AST using Handlebars.parse(template_str)*/
};
const options: ModificationOptions = {
helper: 'filter',
paramType: HbsNodeTypes.SubExpression,
paramPosition: 2,
modifiers: [(d: string) => `'${d}'`],
};
const template = convertAstToString(ast, options);
convertAstToString(node: hbs.AST.Node | null, options: ModificationOptions): string
The ModificationOptions
interface is used to define a set of options for making modifications to a specific node or
element in a Handlebars.js (Hbs) template. This interface is typically used in the context of custom Handlebars.js
helpers or modifiers.
helper
: A string that specifies the name of the helper function. This property is optional and can be used to
associate a modification with a particular helper.
paramType
: An enumeration that represents the type of param that you want to modify. You can use HbsNodeType
to
specify the node type.
paramPosition
: An integer that specifies the position of the parameter you want to modify. This is useful when
dealing with helper parameters.
modifiers
: An array of functions that define the modifications to be applied. Each function in the array should
implement the logic for the modification.
Here's an example of how to use the ModificationOptions
interface in TypeScript:
const options: ModificationOptions = {
helper: 'customHelper',
paramType: HbsNodeType.Block,
paramPosition: 2,
modifiers: [
(parameterValue) => {
// Implement your modification logic here.
// Modify the 'parameterValue' as needed.
},
...
],
};
Refer to spec file for more details.
MIT
FAQs
Converts Handlebars Abstract Syntax Tree (AST) back to template string.
We found that hbs-ast-to-str demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.