Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
cirru-html
Advanced tools
A template engine that converts Cirru to HTML.
See demos on http://repo.cirru.org/html
npm install --save cirru-html
{makeRender, render, setResolver} = require 'cirru-html'
code = 'span (= cirru code)'
data = {}
renderer = makeRender code, {}
renderer {} # pass in data # => '<span>cirru code</span>'
render code, data # => '<span>cirru code</span>'
makeRender
template
is a code string in Cirru,
or a JSON Object of parsed Cirru code (with cirruParser.pare
).
renderer
is a cached renderer that make it fast.
data
is optional.
In Node, you need data['@filename']
to run @insert
and @partial
.
render
Shorthand for using renderer
in one call:
exports.render = (template, data) ->
render = exports.makeRender template, data
render data
setResolver
Solution for reading file is taken out from the module.
html = require 'cirru-html'
html.setResolver (basePath, child, scope) ->
dest = path.join (path.dirname basePath), child
scope?['@filename'] = dest
html = fs.readFileSync dest, 'utf8'
setResolver (basePath, child, scope) ->
match = child.match /(\w+)\.cirru/
element = q "##{match[1]} .file"
element.value or element.innerHTML
Here's a demo of HTML:
doctype
html
head
title "Cirru HTML"
meta $ :charset utf-8
link (:rel stylesheet) $ :href css/style.css
script (:defer) $ :src build/build.js
body
#entry
@repeat (@ names)
.test
:id (@ @value)
textarea.file
textarea.data
button.button " =>"
textarea.result
Notice: the compiled HTML is not prettified.
@
@if
@block
@repeat
@with
@insert
@partial
Functions may also be passed into the renderer to apply on the data.
Steps of rendering:
Cirru Code
-> Syntax Tree
-> Abstract Syntax Tree, based on Classes
-> Cached Tree, HTML data converted
-> Rendering
Classes for rendering HTML:
SingleTag
PairTag
TextTag
Classes for expressions
AtExpression
IfExpression
RepeatExpression &key, &value
WithExpression
InsertExpression
PartialExpression
BlockExpression
MethodsExpression
Filenames passed to @insert
and @partial
are only names.
data
parameters contain at least @filename
and @methods: []
.
0.2.2
0.2.1
with
Since 0.2
, renderer
is removed
MIT
FAQs
Template engine that converts Cirru to HTML
The npm package cirru-html receives a total of 3 weekly downloads. As such, cirru-html popularity was classified as not popular.
We found that cirru-html 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
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.