![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Manila is a no-frills template engine for Node 4+.
npm install manila
// index.js
const app = require('express')(),
manila = require('manila')();
app.get('/', (req, res) => {
res.render('index', {
message: 'Hello, world!'
});
});
// Pass Manila to Express
app.engine('mnla', manila);
// Register Manila as a view engine
app.set('view engine', 'mnla');
// Set the views directory
app.set('views', './views');
app.listen(3000);
<!-- views/index.mnla -->
<h1><:message:></h1>
Run node index
and open http://localhost:3000
in your browser to see the rendered result.
// index.js
const http = require('http'),
manila = require('manila')();
http.createServer((req, res) => {
manila('index.mnla', { message: 'Hello, world!' }, function(err, html) {
res.writeHead(200, 'text/html; charset=UTF-8');
res.end(html);
});
}).listen(3000);
<!-- views/index.mnla -->
<h1><:message:></h1>
When calling manila
, you can either provide a callback or use a promise. The following is effectively the same as the example above:
// index.js
const http = require('http'),
manila = require('manila')();
http.createServer((req, res) => {
manila('index.mnla', { message: 'Hello, world!' })
.then(html => {
res.writeHead(200, 'text/html; charset=UTF-8');
res.end(html);
}).catch(err => {
console.trace(err);
});
}).listen(3000);
The Manila module accepts a configuration object with the following optional properties:
root
: the absolute path to the root of your app. Defaults to the directory which contains the application entry point.
views
: the path to the directory in which to look for views, relative to the root. Defaults to 'views'.
partials
: the directory in which to look for partial mnla files to use with <: include ... :>
tags, realtive to the root. Defaults to views
.
extension
: the file extension of your views/partials. Defaults to '.mnla'
.
// defaults:
const manila = require('manila')({
root: path.dirname(require.main.filename),
views: 'views',
partials: 'views',
extension: '.mnla'
});
<:expression:>
This tag will be replaced with the HTML-escaped result of evaluating the expression or variable with the current context.
<::expression::>
Use two colons instead of one to prevent HTML-escaping of the expression.
<: include path/to/file :>
Includes the content of the named file as part of the current template. path/to/file
is relative to views/
unless overwritten during configuration.
Manila tags are executed as plain 'ol JavaScript, so there's no template language to learn. While you can use any JavaScript you want, here are some examples:
<: if (expression) { :>
<p>This markup renders if expression is truthy</p>
<: } else { :>
<p>This markup renders if expression is falsy</p>
<: } :>
<: list.forEach(item => { :>
<li><:item:></li>
<: }) :>
<: for (key in obj) { :>
<li> <:key:> is <:obj[key]:> </li>
<: } :>
FAQs
A simple template engine for Node
The npm package manila receives a total of 8 weekly downloads. As such, manila popularity was classified as not popular.
We found that manila 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
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.