
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
medium-templater
Advanced tools
It's like a tiny-templater but with a little dash of logic.
var language = require('medium-templater')
var template_string
, template
, compile
template_string =
'<ul>' +
'{% for item in items %}' +
'<li>{% if item.okay %}okay{% else %}not okay{% endif %}</li>' +
'{% endfor %}' +
'</ul>' +
'{{ message }}'
compile = language()
template = compile(template_string)
var result = template({
items: [{okay: true}, {okay: false}]
, message: 'hello world'
})
console.log(result) // <ul><li>okay</li><li>not okay</li></ul>hello world
Though you get if and for for free, you can also provide your own tags
(or override the defaults if you don't like how they work!) like so:
index.jsvar language = require('medium-templater')
, reverse = require('./lib/reverse')
language({
reverse: reverse
})
./lib/reverse.jsmodule.exports = reverse
function reverse(parser, tag_options) {
var contents = ''
parser.parse({'endreverse': end_reverse})
return function(context) {
// context is what is passed to the template, irrelevant in this example.
return contents().split('').reverse().join('')
}
function end_reverse(tpl) {
contents = tpl
}
}
now you can:
{% reverse %}
!sredner etalpmet eht nehw thgir eb lliw txet siht
{% endreverse %}
Specifying reversed at the end of a for statement
(ie for item in items reversed) will parse the items in reverse. Specifying
an {% empty %} tag after the {% for ... %} will return that chunk in the
event of no items.
MIT
FAQs
smarter than your average tiny-templater
We found that medium-templater 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.