
Research
/Security News
Miasma Mini Shai-Hulud Hits ImmobiliareLabs npm Packages
Miasma Mini Shai-Hulud hits @immobiliarelabs Backstage plugins, targeting GitLab and LDAP auth packages on npm.
egg-view-twig-x
Advanced tools
egg view plugin for twig.
$ npm i egg-view-twig --save
// {app_root}/config/plugin.js
exports.twig = {
enable: true,
package: 'egg-view-twig',
};
// {app_root}/config/config.default.js
exports.view = {
mapping: {
'.twig': 'twig',
},
};
// twig config
exports.twig = {};
Create a twig file
// app/view/hello.twig
hello {{ data }}
Render it
// app/controller/render.js
exports.twig = function* () {
yield ctx.render('hello.twig', {
data: 'world',
});
};
The file will be compiled and cached, you can change config.twig.cache = false to disable cache, it's disable in local env by default.
You can include both relative and absolute file.
Relative file is resolve from current file path.
// app/view/a.twig include app/view/b.twig
{% include 'b.twig' %}
Absolute file is resolve from app/view.
// app/view/home.twig include app/view/partial/menu.twig
{% include '/partial/menu.twig' %}
You can render a view with layout also:
// app/view/layout.twig
{% include 'header.twig' %}
{% block content %}{% endblock %}
{% include 'footer.twig' %}
// app/view/hello.twig
{% extends 'layout.twig' %}
{% block content %}
Hello {{ data }}, I'm content.
{% endblock %}
// app/controller/render.js
exports.twig = function* () {
const locals = {
data: 'world',
};
yield ctx.render('hello.twig', locals);
};
see config/config.default.js for more detail.
Please open an issue here.
FAQs
egg view plugin for twig
The npm package egg-view-twig-x receives a total of 3 weekly downloads. As such, egg-view-twig-x popularity was classified as not popular.
We found that egg-view-twig-x 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.

Research
/Security News
Miasma Mini Shai-Hulud hits @immobiliarelabs Backstage plugins, targeting GitLab and LDAP auth packages on npm.

Security News
Rolldown paused Rust React Compiler integration after a 5MB binary size increase raised concerns about shipping React-specific code to all Vite users.

Security News
/Research
Mini Shai-Hulud expands into the Go ecosystem after hitting LeoPlatform npm packages and targeting GitHub Actions workflows.