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.
Razor Leaf is a template engine for HTML. It is indentation-based and vaguely resembles Jade (among others).
doctype
html
head
meta charset: 'utf-8'
title 'Hello, world!'
for script in data.scripts
script type: 'text/javascript' src: '#{script.url}'
if script.async
async:
for stylesheet in data.stylesheets
link
rel: 'stylesheet'
type: 'text/css'
href: '#{stylesheet.url}'
body
h1 id: 'title'
'An example'
p id: 'content' 'This template demonstrates ' em 'most'
' of Razor Leaf’s features.'
var fs = require("fs");
var razorleaf = require("razorleaf");
var template = razorleaf.compile(fs.readFileSync("views/template.leaf", "utf8"));
console.log(template(data));
razorleaf.compile(template)
Compiles a template and returns a function that renders the template
and returns the result, taking an optional data
argument usable inside
the template.
There are four types of “items”.
An element is defined by a name and may be followed on the same line by any number of attributes and strings, and up to one element. If the element is not inline (that is, on the same line as another element), it may followed by an indented block containing any number of elements, attributes, strings, and special blocks.
Attributes use the syntax name: 'value'
. The value is optional, and must be a
string if provided. If a value is not provided, the attribute is assumed to be
boolean.
Strings may be delimited by either single or double quotes. Any expression
between #{
and }
is interpolated. When interpolating, quotes do not need to
be escaped, but a closing brace (}
) does. Strings’ contents are escaped as
appropriate.
for (identifier) in (expression)
will evaluate (expression)
(the
remainder of the line) as JavaScript and iterate over the result. for
blocks cannot directly contain attributes.
if (expression)
will evaluate (expression)
(the remainder of the line) as
JavaScript and include the block if the result is truthy (by the same rules
as JavaScript’s if
).
doctype
will insert the string <!DOCTYPE html>
.
FAQs
A template engine for HTML
The npm package razorleaf receives a total of 2 weekly downloads. As such, razorleaf popularity was classified as not popular.
We found that razorleaf 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.