### Install Dependencies and Build Project
Source: https://github.com/handlebars-lang/handlebars.js/blob/master/tests/browser/README.md
Installs project dependencies and builds the project before running tests.
```bash
pnpm install
pnpm run build
```
--------------------------------
### Install Project Dependencies
Source: https://github.com/handlebars-lang/handlebars.js/blob/master/CONTRIBUTING.md
Install all necessary project dependencies using pnpm, the project's package manager.
```bash
pnpm install
```
--------------------------------
### Inline Decorator Example
Source: https://github.com/handlebars-lang/handlebars.js/blob/master/docs/decorators-api.md
This example demonstrates how an inline decorator can be used to add metadata and wrap a block's functionality. It shows the decorator function signature and how it interacts with `props` and the `program`.
```javascript
import { create } from "@handlebars/allow-prototype-access";
import * as Handlebars from "handlebars/dist/cjs/handlebars";
const options = {
knownHelpers: {
// helpers
},
knownHelpersOnly: true,
allowProtoMethods: {
// proto methods
},
allowProtoProperties: {
// proto properties
},
allowConditionalEvals: true
};
const runtimeOptions = {
// runtime options
};
const runtime = create(Handlebars.compile, options);
const template = runtime(
`{{#* inline "my-decorator"}}
{{#* inline "my-decorator-inner"}}
{{> @partial-block}}
{{/inline}}
{{my-decorator-inner}}
{{/inline}}
{{#my-decorator}}
Hello {{name}}!
{{/my-decorator}}`,
runtimeOptions
);
const data = {
name: "World"
};
console.log(template(data));
// Decorator function definition
function myDecorator(program, props) {
props.foo = "bar";
return function(context, options) {
return "Decorated: " + program(context, options);
};
}
```
--------------------------------
### Release Latest Version
Source: https://github.com/handlebars-lang/handlebars.js/blob/master/CONTRIBUTING.md
Commands to perform a full release of the latest version, including dependency installation, building, and publishing.
```sh
pnpm install --frozen-lockfile
pnpm run build
pnpm publish
```
--------------------------------
### Custom Handlebars Compiler with Lowercase Lookup
Source: https://github.com/handlebars-lang/handlebars.js/blob/master/docs/compiler-api.md
Illustrates how to create a custom Handlebars compiler that modifies property lookups. This example changes all context property lookups to be case-insensitive using a helper. Ensure the helper is registered before compiling templates.
```javascript
function MyCompiler() {
Handlebars.JavaScriptCompiler.apply(this, arguments);
}
MyCompiler.prototype = new Handlebars.JavaScriptCompiler();
// Use this compile to compile BlockStatment-Blocks
MyCompiler.prototype.compiler = MyCompiler;
MyCompiler.prototype.nameLookup = function (parent, name, type) {
if (type === 'context') {
return this.source.functionCall('helpers.lookupLowerCase', '', [
parent,
JSON.stringify(name),
]);
} else {
return Handlebars.JavaScriptCompiler.prototype.nameLookup.call(
this,
parent,
name,
type
);
}
};
var env = Handlebars.create();
env.registerHelper('lookupLowerCase', function (parent, name) {
return parent[name.toLowerCase()];
});
env.JavaScriptCompiler = MyCompiler;
var template = env.compile('{{#each Test}} ({{Value}}) {{/each}}');
console.log(
template({
test: [{ value: 'a' }, { value: 'b' }, { value: 'c' }],
})
);
```
--------------------------------
### Disallow Constructor Access for Security
Source: https://github.com/handlebars-lang/handlebars.js/blob/master/release-notes.md
This security fix prohibits access to class constructors within templates to prevent Remote Code Execution (RCE). The example demonstrates how direct constructor access is now blocked.
```javascript
class SomeClass {
}
SomeClass.staticProperty = 'static'
var template = Handlebars.compile('{{constructor.staticProperty}}');
document.getElementById('output').innerHTML = template(new SomeClass());
// expected: 'static', but now this is empty.
```
--------------------------------
### Use Node 10 for Building
Source: https://github.com/handlebars-lang/handlebars.js/blob/master/release-notes.md
Configures the build process to use Node.js version 10.
```none
chore: Use node 10 to build handlebars - 78dd89c
```
--------------------------------
### Initialize Git Submodule
Source: https://github.com/handlebars-lang/handlebars.js/blob/master/CONTRIBUTING.md
Ensure the Git submodule 'spec/mustache' is included. Use this command if you cloned without the --recursive flag.
```bash
git submodule update --init
```
--------------------------------
### Use Custom Grunt-Saucelab
Source: https://github.com/handlebars-lang/handlebars.js/blob/master/release-notes.md
Updates the project to use a custom 'grunt-saucelab' configuration with the current Sauce Connect proxy for testing.
```none
Use custom `grunt-saucelab` with current sauce-connect proxy - f119497
```
--------------------------------
### Add More Release Documentation
Source: https://github.com/handlebars-lang/handlebars.js/blob/master/release-notes.md
Enhances the release documentation with additional details and guidance.
```none
chore/doc: Add more release docs - 6b87c21
```
--------------------------------
### Run Integration Tests
Source: https://github.com/handlebars-lang/handlebars.js/blob/master/CONTRIBUTING.md
Execute integration tests for bundler compatibility. Note: These tests only work on Linux.
```sh
pnpm run test:integration
```
--------------------------------
### Run Tests
Source: https://github.com/handlebars-lang/handlebars.js/blob/master/CONTRIBUTING.md
Execute the project's test suite to ensure code integrity after building.
```bash
pnpm test
```
--------------------------------
### Typical Branch Comparison Workflow
Source: https://github.com/handlebars-lang/handlebars.js/blob/master/README.md
A common workflow for comparing performance between the main branch and a feature branch using Handlebars.js benchmarks.
```bash
git checkout main && pnpm run bench
git checkout my-feature && pnpm run bench
pnpm run bench:compare
```
--------------------------------
### Run Handlebars.js Benchmarks
Source: https://github.com/handlebars-lang/handlebars.js/blob/master/README.md
Execute the comprehensive benchmark suite for Handlebars.js. This command automatically labels results with the current git branch.
```bash
pnpm run bench
```
--------------------------------
### Add Framework for Integration Tests
Source: https://github.com/handlebars-lang/handlebars.js/blob/master/release-notes.md
Introduces a new framework to support various integration tests, improving the testing infrastructure.
```none
Add framework for various integration tests - f9cce4d
```
--------------------------------
### Build Handlebars.js
Source: https://github.com/handlebars-lang/handlebars.js/blob/master/CONTRIBUTING.md
Compile CJS modules and bundle UMD distributions to the dist/ folder. This command builds the project from scratch.
```bash
pnpm run build
```
--------------------------------
### Compare Benchmark Results
Source: https://github.com/handlebars-lang/handlebars.js/blob/master/README.md
Compare the results of different benchmark runs. This command is useful for assessing performance changes between branches or versions.
```bash
pnpm run bench:compare
```
--------------------------------
### Run Browser Tests with Docker
Source: https://github.com/handlebars-lang/handlebars.js/blob/master/tests/browser/README.md
Executes the browser tests within a Docker container, mounting the project directory and setting the working directory.
```bash
docker run -it --rm --volume $(pwd):/srv/app --workdir /srv/app --ipc=host mcr.microsoft.com/playwright:focal sh -c "corepack enable && pnpm run test:browser"
```
--------------------------------
### Compare Specific Benchmark Result Files
Source: https://github.com/handlebars-lang/handlebars.js/blob/master/README.md
Compare benchmark results by explicitly specifying the Markdown files containing the results to be compared.
```bash
pnpm run bench:compare -- bench/results/bench-*-main.md bench/results/bench-*-feat.md
```
--------------------------------
### Run Benchmarks with Custom Label
Source: https://github.com/handlebars-lang/handlebars.js/blob/master/README.md
Run Handlebars.js benchmarks and apply a custom label to the results for easier identification.
```bash
pnpm run bench -- --label my-optimization
```
--------------------------------
### Parse Template to AST and Precompile
Source: https://github.com/handlebars-lang/handlebars.js/blob/master/docs/compiler-api.md
Demonstrates parsing a Handlebars template string into an AST and then precompiling it. The AST can be manipulated before precompilation.
```javascript
var ast = Handlebars.parse(myTemplate);
// Modify ast
Handlebars.precompile(ast);
```
--------------------------------
### Import Typescript Typings
Source: https://github.com/handlebars-lang/handlebars.js/blob/master/release-notes.md
Introduces TypeScript typings to the project, enabling better type checking and developer experience for TypeScript users.
```typescript
import TypeScript typings - 27ac1ee
```
--------------------------------
### Clone Mustache Specs
Source: https://github.com/handlebars-lang/handlebars.js/blob/master/CONTRIBUTING.md
Clone the mustache specifications into the spec/mustache directory to run tests.
```sh
cd spec
rm -r mustache
git clone https://github.com/mustache/spec.git mustache
```
--------------------------------
### AST Visitor
Source: https://github.com/handlebars-lang/handlebars.js/blob/master/docs/compiler-api.md
The `Handlebars.Visitor` class provides a base for traversing the Abstract Syntax Tree (AST). You can override specific methods to hook into different node types during traversal. It supports both standard traversal and mutation mode.
```APIDOC
## AST Visitor
`Handlebars.Visitor` is available as a base class for general interaction with AST structures. This will by default traverse the entire tree and individual methods may be overridden to provide specific responses to particular nodes.
Recording all referenced partial names:
```javascript
var Visitor = Handlebars.Visitor;
function ImportScanner() {
this.partials = [];
}
ImportScanner.prototype = new Visitor();
ImportScanner.prototype.PartialStatement = function (partial) {
this.partials.push({ request: partial.name.original });
Visitor.prototype.PartialStatement.call(this, partial);
};
var scanner = new ImportScanner();
scanner.accept(ast);
```
The current node's ancestors will be maintained in the `parents` array, with the most recent parent listed first.
The visitor may also be configured to operate in mutation mode by setting the `mutating` field to true. When in this mode, handler methods may return any valid AST node and it will replace the one they are currently operating on. Returning `false` will remove the given value (if valid) and returning `undefined` will leave the node intact. This return structure only apply to mutation mode and non-mutation mode visitors are free to return whatever values they wish.
Implementors that may need to support mutation mode are encouraged to utilize the `acceptKey`, `acceptRequired` and `acceptArray` helpers which provide the conditional overwrite behavior as well as implement sanity checks where pertinent.
```
--------------------------------
### Enable Corepack for pnpm
Source: https://github.com/handlebars-lang/handlebars.js/blob/master/CONTRIBUTING.md
Enable Corepack to automatically use the pnpm version specified in package.json. This command only needs to be run once.
```bash
corepack enable
```
--------------------------------
### Scanning Partial Statements with a Visitor
Source: https://github.com/handlebars-lang/handlebars.js/blob/master/docs/compiler-api.md
Demonstrates how to extend the Handlebars Visitor to scan an AST and record all referenced partial names. This involves overriding the PartialStatement method.
```javascript
var Visitor = Handlebars.Visitor;
function ImportScanner() {
this.partials = [];
}
ImportScanner.prototype = new Visitor();
ImportScanner.prototype.PartialStatement = function (partial) {
this.partials.push({ request: partial.name.original });
Visitor.prototype.PartialStatement.call(this, partial);
};
var scanner = new ImportScanner();
scanner.accept(ast);
```
--------------------------------
### Pull Playwright Docker Image
Source: https://github.com/handlebars-lang/handlebars.js/blob/master/tests/browser/README.md
Pulls the necessary Docker image for Playwright testing.
```bash
docker pull mcr.microsoft.com/playwright:focal
```
--------------------------------
### Lint and Format Code
Source: https://github.com/handlebars-lang/handlebars.js/blob/master/CONTRIBUTING.md
Use these scripts to ensure code quality and formatting. 'pnpm run lint' runs all linters, 'pnpm run format' formats files, and 'pnpm run check-before-pull-request' performs pre-CI checks.
```sh
pnpm run lint
```
```sh
pnpm run format
```
```sh
pnpm run check-before-pull-request
```
--------------------------------
### Filter Benchmark Templates by Name
Source: https://github.com/handlebars-lang/handlebars.js/blob/master/README.md
Run benchmarks, filtering the templates to be tested by a case-insensitive regex pattern matching their names.
```bash
pnpm run bench -- --grep "complex|recursive"
```
--------------------------------
### Program Interface
Source: https://github.com/handlebars-lang/handlebars.js/blob/master/docs/compiler-api.md
Represents a program within the Handlebars AST, containing a body of statements and block parameters.
```APIDOC
## Program Interface
### Program
```java
interface Program <: Node {
type: "Program";
body: [ Statement ];
blockParams: [ string ];
}
```
```
--------------------------------
### Compile and Render Handlebars Template
Source: https://github.com/handlebars-lang/handlebars.js/blob/master/README.md
Compiles a Handlebars template string into a function and then renders it with provided data. Ensure the Handlebars library is included before using this.
```javascript
var source =
'
Hello, my name is {{name}}. I am from {{hometown}}. I have ' +
'{{kids.length}} kids:
' +
'{{#kids}}- {{name}} is {{age}}
{{/kids}}
';
var template = Handlebars.compile(source);
var data = {
name: 'Alan',
hometown: 'Somewhere, TX',
kids: [
{ name: 'Jimmy', age: '12' },
{ name: 'Sally', age: '4' },
],
};
var result = template(data);
```
--------------------------------
### Run Specific Benchmark Sections
Source: https://github.com/handlebars-lang/handlebars.js/blob/master/README.md
Execute only specific sections of the Handlebars.js benchmark suite, identified by a case-insensitive regex pattern.
```bash
pnpm run bench -- --section precompil
```
```bash
pnpm run bench -- --section "compilation|precompil"
```
--------------------------------
### Replace Async with Neo-Async
Source: https://github.com/handlebars-lang/handlebars.js/blob/master/release-notes.md
Refactors the codebase to use 'neo-async' instead of the older 'async' library.
```javascript
replace "async" with "neo-async" - 048f2ce
```
--------------------------------
### Check Handlebars CLI version
Source: https://github.com/handlebars-lang/handlebars.js/blob/master/FAQ.md
Verify the version of the Handlebars command-line interface (CLI) tool. This is useful for ensuring compatibility with precompiled templates.
```sh
handlebars --version
```
--------------------------------
### Check Handlebars client-side version
Source: https://github.com/handlebars-lang/handlebars.js/blob/master/FAQ.md
Log the Handlebars runtime version in the browser console. This helps in debugging version mismatches between the precompiler and the client library.
```javascript
console.log(Handlebars.VERSION);
```
--------------------------------
### AST Node Interfaces
Source: https://github.com/handlebars-lang/handlebars.js/blob/master/docs/compiler-api.md
Defines the basic structure for AST nodes, including type and location information.
```APIDOC
## AST Node Interfaces
### Node
```java
interface Node {
type: string;
loc: SourceLocation | null;
}
```
### SourceLocation
```java
interface SourceLocation {
source: string | null;
start: Position;
end: Position;
}
```
### Position
```java
interface Position {
line: uint >= 1;
column: uint >= 0;
}
```
```
--------------------------------
### Integrate Webpack Test
Source: https://github.com/handlebars-lang/handlebars.js/blob/master/release-notes.md
Adds an integration test specifically for Webpack to ensure compatibility and proper functioning with the module bundler.
```none
Add integration test for webpack - a57b682
```
--------------------------------
### Fix Components/Handlebars Package.json
Source: https://github.com/handlebars-lang/handlebars.js/blob/master/release-notes.md
Corrects the 'package.json' file for the 'components/handlebars' package and ensures it auto-updates during the release process.
```none
chore: fix components/handlebars package.json and auto-update on release - bacd473
```
--------------------------------
### Add Runtime Typescript Definitions
Source: https://github.com/handlebars-lang/handlebars.js/blob/master/release-notes.md
Ensures that 'runtime.d.ts' is included, allowing 'require(\'handlebars/runtime\')' to work correctly in TypeScript projects.
```typescript
fix: add "runtime.d.ts" to allow "require('handlebars/runtime')" in TypeScript - 5cedd62
```
--------------------------------
### Add Missing Typescript Dependency
Source: https://github.com/handlebars-lang/handlebars.js/blob/master/release-notes.md
Includes the missing TypeScript dependency and adds a 'package-lock.json' file to manage project dependencies.
```none
chore: add missing typescript dependency, add package-lock.json - 594f1e3
```
--------------------------------
### Run Handlebars UMD Smoke Test
Source: https://github.com/handlebars-lang/handlebars.js/blob/master/spec/index.html
This script performs a series of assertions to validate the Handlebars UMD build. It checks for the existence of Handlebars, its compile and template functions, and the version string. It also tests basic template compilation.
```javascript
var results = document.getElementById('results'); var failures = 0; var tests = 0; function assert(condition, message) { tests++; if (!condition) { failures++; results.textContent += 'FAIL: ' + message + '\n'; } else { results.textContent += 'PASS: ' + message + '\n'; } } try { assert(typeof Handlebars !== 'undefined', 'Handlebars is defined'); assert( typeof Handlebars.compile === 'function', 'Handlebars.compile exists' ); assert( typeof Handlebars.template === 'function', 'Handlebars.template exists' ); assert( typeof Handlebars.VERSION === 'string', 'Handlebars.VERSION exists' ); var template = Handlebars.compile('Hello {{name}}!'); var output = template({ name: 'World' }); assert(output === 'Hello World!', 'Basic compilation works: ' + output); } catch (e) { failures++; results.textContent += 'ERROR: ' + e.message + '\n'; } results.textContent += '\n' + tests + ' tests, ' + failures + ' failures\n'; window.mochaResults = { passes: tests - failures, failures: failures };
```
--------------------------------
### Hash and HashPair AST Nodes
Source: https://github.com/handlebars-lang/handlebars.js/blob/master/docs/compiler-api.md
Defines the structures for hash arguments and their key-value pairs within the Handlebars AST.
```java
interface Hash <: Node {
type: "Hash";
pairs: [ HashPair ];
}
interface HashPair <: Node {
type: "HashPair";
key: string;
value: Expression;
}
```
--------------------------------
### Registering Decorators
Source: https://github.com/handlebars-lang/handlebars.js/blob/master/docs/decorators-api.md
Use `registerDecorators` to make decorators available in templates. This function takes an object where keys are decorator names and values are the decorator functions.
```javascript
Handlebars.registerDecorators({
// decorator definitions
});
```
--------------------------------
### Port Linting and Typings Test
Source: https://github.com/handlebars-lang/handlebars.js/blob/master/release-notes.md
Ports existing linting rules and adds tests for TypeScript typings to ensure code quality and type safety.
```none
#1515 - Port over linting and test for typings ([@zimmi88](https://api.github.com/users/zimmi88))
```
--------------------------------
### JavaScript Compiler Customizations
Source: https://github.com/handlebars-lang/handlebars.js/blob/master/docs/compiler-api.md
The `Handlebars.JavaScriptCompiler` class offers methods that can be overridden to customize the generated JavaScript output of the Handlebars compiler.
```APIDOC
## JavaScript Compiler
The `Handlebars.JavaScriptCompiler` object has a number of methods that may be customized to alter the output of the compiler:
- `nameLookup(parent, name, type)`
Used to generate the code to resolve a given path component.
- `parent` is the existing code in the path resolution
- `name` is the current path component
- `type` is the type of name being evaluated. May be one of `context`, `data`, `helper`, `decorator`, or `partial`.
Note that this does not impact dynamic partials, which implementors need to be aware of. Overriding `VM.resolvePartial` may be required to support dynamic cases.
- `depthedLookup(name)`
Used to generate code that resolves parameters within any context in the stack. Is only used in `compat` mode.
- `compilerInfo()`
Allows for custom compiler flags used in the runtime version checking logic.
- `appendToBuffer(source, location, explicit)`
Allows for code buffer emitting code. Defaults behavior is string concatenation.
- `source` is the source code whose result is to be appending
- `location` is the location of the source in the source map.
- `explicit` is a flag signaling that the emit operation must occur, vs. the lazy evaled options otherwise.
- `initializeBuffer()`
Allows for buffers other than the default string buffer to be used. Generally needs to be paired with a custom `appendToBuffer` implementation.
```
--------------------------------
### Deprecated Helper/Partial Signature
Source: https://github.com/handlebars-lang/handlebars.js/blob/master/release-notes.md
The older signature for passing custom helpers or partials to templates is deprecated. Avoid using this format in new code and update existing codebases.
```javascript
template(context, helpers, partials, [data]);
```
--------------------------------
### Expression Interfaces
Source: https://github.com/handlebars-lang/handlebars.js/blob/master/docs/compiler-api.md
Defines the base interface for expressions within the Handlebars AST.
```APIDOC
## Expression Interfaces
### Expression
```java
interface Expression <: Node { }
```
### SubExpression
```java
interface SubExpression <: Expression {
type: "SubExpression";
path: PathExpression;
params: [ Expression ];
hash: Hash;
}
```
```
--------------------------------
### Upgrade Helper/Partial Signature
Source: https://github.com/handlebars-lang/handlebars.js/blob/master/release-notes.md
When upgrading from Handlebars 0.9 series, the signature for passing custom helpers or partials to templates has changed. Use the new object-based signature for clarity and consistency.
```javascript
template(context, { helpers: helpers, partials: partials, data: data });
```
--------------------------------
### Handlebars AST Node Interface
Source: https://github.com/handlebars-lang/handlebars.js/blob/master/docs/compiler-api.md
Defines the basic structure for AST nodes, including type and source location information.
```typescript
interface Node {
type: string;
loc: SourceLocation | null;
}
interface SourceLocation {
source: string | null;
start: Position;
end: Position;
}
interface Position {
line: uint >= 1;
column: uint >= 0;
}
```
--------------------------------
### Prevent RCE via Lookup Helper
Source: https://github.com/handlebars-lang/handlebars.js/blob/master/release-notes.md
This fix prevents Remote Code Execution (RCE) by disallowing access to the 'constructor' property through the 'lookup' helper. This addresses a security vulnerability.
```javascript
fix: prevent RCE through the "lookup"-helper - cd38583
```
--------------------------------
### Statement Interfaces
Source: https://github.com/handlebars-lang/handlebars.js/blob/master/docs/compiler-api.md
Defines various types of statements that can exist within a Handlebars AST program.
```APIDOC
## Statement Interfaces
### Statement
```java
interface Statement <: Node { }
```
### MustacheStatement
```java
interface MustacheStatement <: Statement {
type: "MustacheStatement";
path: PathExpression | Literal;
params: [ Expression ];
hash: Hash;
escaped: boolean;
strip: StripFlags | null;
}
```
### BlockStatement
```java
interface BlockStatement <: Statement {
type: "BlockStatement";
path: PathExpression | Literal;
params: [ Expression ];
hash: Hash;
program: Program | null;
inverse: Program | null;
openStrip: StripFlags | null;
inverseStrip: StripFlags | null;
closeStrip: StripFlags | null;
}
```
### PartialStatement
```java
interface PartialStatement <: Statement {
type: "PartialStatement";
name: PathExpression | SubExpression;
params: [ Expression ];
hash: Hash;
indent: string;
strip: StripFlags | null;
}
```
### PartialBlockStatement
```java
interface PartialBlockStatement <: Statement {
type: "PartialBlockStatement";
name: PathExpression | SubExpression;
params: [ Expression ];
hash: Hash;
program: Program | null;
indent: string;
openStrip: StripFlags | null;
closeStrip: StripFlags | null;
}
```
### ContentStatement
```java
interface ContentStatement <: Statement {
type: "ContentStatement";
value: string;
original: string;
}
```
### CommentStatement
```java
interface CommentStatement <: Statement {
type: "CommentStatement";
value: string;
strip: StripFlags | null;
}
```
### Decorator
```java
interface Decorator <: Statement {
type: "Decorator";
path: PathExpression | Literal;
params: [ Expression ];
hash: Hash;
strip: StripFlags | null;
}
```
### DecoratorBlock
```java
interface DecoratorBlock <: Statement {
type: "DecoratorBlock";
path: PathExpression | Literal;
params: [ Expression ];
hash: Hash;
program: Program | null;
openStrip: StripFlags | null;
closeStrip: StripFlags | null;
}
```
```
--------------------------------
### Handlebars Security Fixes (v4.5.3)
Source: https://github.com/handlebars-lang/handlebars.js/blob/master/release-notes.md
Properties like `__proto__`, `__defineGetter__`, `__defineSetter__`, and `__lookupGetter__` are now handled to prevent Remote-Code-Execution exploits. If a property by that name is found and not enumerable on its parent, it will silently evaluate to `undefined`.
```javascript
/*
The properties `__proto__`, `__defineGetter__`, `__defineSetter__` and `__lookupGetter__`
have been added to the list of "properties that must be enumerable".
If a property by that name is found and not enumerable on its parent,
it will silently evaluate to `undefined`. This is done in both the compiled template and the "lookup"-helper.
This will prevent new Remote-Code-Execution exploits that have been
published recently.
*/
// Example of a case that now returns undefined:
// {{ __proto__ }}
// Example of a case where semantics have not changed (property is enumerable):
// {
// __proto__: 'some string'
// }
```
--------------------------------
### Remove Safari from Saucelabs
Source: https://github.com/handlebars-lang/handlebars.js/blob/master/release-notes.md
Removes Safari from the list of browsers tested on Sauce Labs, likely due to configuration changes or test stability.
```none
test: remove safari from saucelabs - 871accc
```
--------------------------------
### Handle Object Prototype Access (v4.6.0)
Source: https://github.com/handlebars-lang/handlebars.js/blob/master/release-notes.md
Access to prototype properties is forbidden by default. Specific properties can be allowed via runtime options. This change aims to prevent prototype pollution vulnerabilities.
```javascript
Handlebars.create({
// Allow specific prototype properties
allowedPrototypeProperties: {
myProp: true
}
});
```
--------------------------------
### Handlebars.parse
Source: https://github.com/handlebars-lang/handlebars.js/blob/master/docs/compiler-api.md
Parses a template string into the Handlebars AST and then updates it to strip extraneous whitespace. It handles whitespace around standalone dynamic statements and applies whitespace control characters.
```APIDOC
## Handlebars.parse
### Description
Parses a template string into the Handlebars AST and then updates it to strip extraneous whitespace. It handles whitespace around standalone dynamic statements and applies whitespace control characters. This method is used internally by `Handlebars.precompile` and `Handlebars.compile`.
### Method
```javascript
Handlebars.parse(myTemplate)
```
### Parameters
#### Path Parameters
- **myTemplate** (string) - Required - The template string to parse.
```
--------------------------------
### Add Browser Property to Package.json
Source: https://github.com/handlebars-lang/handlebars.js/blob/master/release-notes.md
Adds the 'browser' property to package.json, which helps with module resolution in bundlers like Webpack and resolves issue #1102.
```json
added "browser"-property to package.json, resolves #1102 ([@ouijan](https://api.github.com/users/ouijan))
```
--------------------------------
### Include script tags in Handlebars templates
Source: https://github.com/handlebars-lang/handlebars.js/blob/master/FAQ.md
When loading templates via an inlined `
```
--------------------------------
### Handlebars Raw-Blocks Regex (v4.4.5)
Source: https://github.com/handlebars-lang/handlebars.js/blob/master/release-notes.md
Fixes an issue where contents of raw-blocks were not matched with non-eager regex-matching.
```regex
/\{\{\s*raw\s*\}\}([\s\S]*?)\{\{\s*\/raw\s*\}\}/
```
--------------------------------
### Use Substring Function
Source: https://github.com/handlebars-lang/handlebars.js/blob/master/release-notes.md
Replaces the usage of the 'substr' function with the more modern 'substring' function for string manipulation.
```javascript
use "substring"-function instead of "substr" - 445ae12
```
--------------------------------
### Handlebars AST Program Interface
Source: https://github.com/handlebars-lang/handlebars.js/blob/master/docs/compiler-api.md
Defines the structure for a Handlebars AST Program, which contains a body of statements and block parameters.
```typescript
interface Program <: Node {
type: "Program";
body: [ Statement ];
blockParams: [ string ];
}
```
--------------------------------
### Handlebars Raw-Blocks Token Fix (v4.4.4)
Source: https://github.com/handlebars-lang/handlebars.js/blob/master/release-notes.md
Prevents zero-length tokens from being generated within raw-blocks.
```javascript
/*
fix: prevent zero length tokens in raw-blocks (#1577, #1578)
*/
```
--------------------------------
### Handlebars Lookup String Conversion (v4.5.2)
Source: https://github.com/handlebars-lang/handlebars.js/blob/master/release-notes.md
Ensures that `String(field)` is used in lookup operations when checking for the 'constructor' property to prevent potential issues.
```javascript
String(field)
```
--------------------------------
### PathExpression AST Node
Source: https://github.com/handlebars-lang/handlebars.js/blob/master/docs/compiler-api.md
Defines the structure for path expressions in the Handlebars AST. 'data' indicates a @data reference, 'depth' specifies the context level, 'parts' are the path components, and 'original' is the raw path string.
```java
interface PathExpression <: Expression {
type: "PathExpression";
data: boolean;
depth: uint >= 0;
parts: [ string ];
original: string;
}
```
--------------------------------
### Handlebars AST Typings Update (v4.4.3)
Source: https://github.com/handlebars-lang/handlebars.js/blob/master/release-notes.md
Adds missing type fields to AST typings and includes corresponding tests.
```typescript
// Example of AST typings (actual code not provided in source)
```
--------------------------------
### Handlebars.parseWithoutProcessing
Source: https://github.com/handlebars-lang/handlebars.js/blob/master/docs/compiler-api.md
Parses a raw template string into the Handlebars AST without any further processing. This is ideal for codemod tools that require source-to-source transformations.
```APIDOC
## Handlebars.parseWithoutProcessing
### Description
Parses a raw template string into the Handlebars AST without any further processing. This is ideal for codemod tools that require source-to-source transformations.
### Method
```javascript
Handlebars.parseWithoutProcessing(myTemplate)
```
### Parameters
#### Path Parameters
- **myTemplate** (string) - Required - The template string to parse.
```
--------------------------------
### Parse Template to AST Without Whitespace Processing
Source: https://github.com/handlebars-lang/handlebars.js/blob/master/docs/compiler-api.md
Uses `Handlebars.parseWithoutProcessing` to convert a raw template string into a Handlebars AST. This is ideal for source-to-source transformations as it does not modify the AST.
```javascript
let ast = Handlebars.parseWithoutProcessing(myTemplate);
```
--------------------------------
### Literal AST Nodes
Source: https://github.com/handlebars-lang/handlebars.js/blob/master/docs/compiler-api.md
Defines the structures for various literal types within the Handlebars AST, including strings, booleans, numbers, undefined, and null.
```java
interface Literal <: Expression { }
interface StringLiteral <: Literal {
type: "StringLiteral";
value: string;
original: string;
}
interface BooleanLiteral <: Literal {
type: "BooleanLiteral";
value: boolean;
original: boolean;
}
interface NumberLiteral <: Literal {
type: "NumberLiteral";
value: number;
original: number;
}
interface UndefinedLiteral <: Literal {
type: "UndefinedLiteral";
}
interface NullLiteral <: Literal {
type: "NullLiteral";
}
```
--------------------------------
### Handlebars Parse Without Processing (v4.5.0)
Source: https://github.com/handlebars-lang/handlebars.js/blob/master/release-notes.md
Introduces the `Handlebars.parseWithoutProcessing` method, allowing parsing of templates without immediate processing.
```javascript
Handlebars.parseWithoutProcessing(templateString);
```
--------------------------------
### Parse Template to AST With Whitespace Processing
Source: https://github.com/handlebars-lang/handlebars.js/blob/master/docs/compiler-api.md
Uses `Handlebars.parse` to convert a template string into an AST, which includes stripping extraneous whitespace. This method is used internally by `Handlebars.precompile` and `Handlebars.compile`.
```javascript
let ast = Handlebars.parse(myTemplate);
```
--------------------------------
### StripFlags Interface
Source: https://github.com/handlebars-lang/handlebars.js/blob/master/docs/compiler-api.md
Represents whitespace control flags for Handlebars statements, indicating whether to strip whitespace from the open or close side of a statement.
```java
interface StripFlags {
open: boolean;
close: boolean;
}
```
--------------------------------
### Handlebars AST Expression Interface
Source: https://github.com/handlebars-lang/handlebars.js/blob/master/docs/compiler-api.md
Defines the base interface for Handlebars AST expressions.
```typescript
interface Expression <: Node { }
```
--------------------------------
### Handlebars AST Statement Interfaces
Source: https://github.com/handlebars-lang/handlebars.js/blob/master/docs/compiler-api.md
Defines interfaces for various Handlebars AST statement types, including Mustache, Block, Partial, Content, and Comment statements.
```typescript
interface Statement <: Node { }
interface MustacheStatement <: Statement {
type: "MustacheStatement";
path: PathExpression | Literal;
params: [ Expression ];
hash: Hash;
escaped: boolean;
strip: StripFlags | null;
}
interface BlockStatement <: Statement {
type: "BlockStatement";
path: PathExpression | Literal;
params: [ Expression ];
hash: Hash;
program: Program | null;
inverse: Program | null;
openStrip: StripFlags | null;
inverseStrip: StripFlags | null;
closeStrip: StripFlags | null;
}
interface PartialStatement <: Statement {
type: "PartialStatement";
name: PathExpression | SubExpression;
params: [ Expression ];
hash: Hash;
indent: string;
strip: StripFlags | null;
}
interface PartialBlockStatement <: Statement {
type: "PartialBlockStatement";
name: PathExpression | SubExpression;
params: [ Expression ];
hash: Hash;
program: Program | null;
indent: string;
openStrip: StripFlags | null;
closeStrip: StripFlags | null;
}
```
```typescript
interface ContentStatement <: Statement {
type: "ContentStatement";
value: string;
original: string;
}
interface CommentStatement <: Statement {
type: "CommentStatement";
value: string;
strip: StripFlags | null;
}
```
```typescript
interface Decorator <: Statement {
type: "Decorator";
path: PathExpression | Literal;
params: [ Expression ];
hash: Hash;
strip: StripFlags | null;
}
interface DecoratorBlock <: Statement {
type: "DecoratorBlock";
path: PathExpression | Literal;
params: [ Expression ];
hash: Hash;
program: Program | null;
openStrip: StripFlags | null;
closeStrip: StripFlags | null;
}
```
--------------------------------
### Handlebars AST SubExpression Interface
Source: https://github.com/handlebars-lang/handlebars.js/blob/master/docs/compiler-api.md
Defines the structure for a Handlebars AST SubExpression, used for dynamic partials or nested expressions.
```typescript
interface SubExpression <: Expression {
type: "SubExpression";
path: PathExpression;
params: [ Expression ];
hash: Hash;
}
```
--------------------------------
### Unregistering Decorators
Source: https://github.com/handlebars-lang/handlebars.js/blob/master/docs/decorators-api.md
Use `unregisterDecorators` to remove previously registered decorators. This function takes an array of decorator names to unregister.
```javascript
Handlebars.unregisterDecorators(['decoratorName']);
```
=== COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.