Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
twig-loader
Advanced tools
Webpack loader for compiling Twig.js templates. This loader will allow you to require Twig.js views to your code.
npm install twig-loader
module.exports = {
//...
module: {
rules: [
{
test: /\.twig$/,
use: {
loader: 'twig-loader',
options: {
// See options section below
},
}
}
]
},
node: {
fs: "empty" // avoids error messages
}
};
module.exports = {
//...
module: {
rules: [
{
test: /\.twig$/,
loader: "twig-loader",
options: {
// See options section below
},
}
]
},
node: {
fs: "empty" // avoids error messages
}
};
twigOptions
: optional; a map of options to be passed through to Twig.
Example: {autoescape: true}
{# File: dialog.html.twig #}
<p>{{title}}</p>
// File: app.js
var template = require("dialog.html.twig");
// => returns pre-compiled template as a function and automatically includes Twig.js to your project
var html = template({title: 'dialog title'});
// => Render the view with the given context
When you extend another view, it will also be added as a dependency. All twig functions that refer to additional templates are supported: import, include, extends & embed.
twig-loader will only resolve static paths in your templates, according to your webpack configuration. When you want to use dynamic templates or aliases, they cannot be resolved by webpack, and will be left untouched in your template. It is up to you to make sure those templates are available in Twig at runtime by registering them yourself:
var twig = require('twig').twig
twig({
id: 'your-custom-template-id,
data: '<p>your template here</p>',
allowInlineIncludes: true,
rethrow: true
});
Or more advanced when using webpack.context
:
var twig = require('twig').twig
var context = require.context('./templates/', true, /\.twig$/)
context.keys().forEach(key => {
var template = context(key);
twig({
id: key, // key will be relative from `./templates/`
data: template.tokens, // tokens are exported on the template function
allowInlineIncludes: true,
rethrow: true
});
});
embed
supportimport
support (https://github.com/zimmo-be/twig-loader/pull/8).twig
file extension. After upgrading twig-loader, you may need to update your files and add .twig
manuallyFAQs
Webpack loader for compiling twig.js templates
The npm package twig-loader receives a total of 4,721 weekly downloads. As such, twig-loader popularity was classified as popular.
We found that twig-loader 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
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.