Security News
PyPI Introduces Digital Attestations to Strengthen Python Package Security
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
ft-next-express
Advanced tools
Slightly enhanced Express.
Comes with:-
bower_components
)GET /robots.txt
(possibly might need to change in the future)./public
folder via ./{{name-of-app}}
__name
to templatesNODE_ENV
to templates via __environment
__isProduction
is true
if NODE_ENV
equals PRODUCTION
npm install --save ft-next-express
main.js
var express = require('ft-next-express');
var app = express({
// Optional. If name is not provided, next-express will try to infer it from package.json
name: "xian",
// Optional
helpers: {
uppercase: function(options) {
return options.fn(this).toUpperCase();
}
}
});
app.get('/', function(req, res, next) {
res.render('main', {
title: "FT",
image: "https://avatars0.githubusercontent.com/u/3502508?v=3",
date: new Date(),
text : "<p>This wont be shown</p><p>This will be shown</p><p>This wont be shown</p>"
});
});
app.listen(process.env.PORT, function() {
console.log("Listening on " + process.env.PORT);
});
views/main.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>{{title}}</title>
<!-- this will be output as <link rel="stylesheet" href="/xian/main.css"> -->
<link rel="stylesheet" href="/{{__name}}/main.css">
</head>
<body>
<h1>{{title}}</h1>
{{#uppercase}}this text will be uppercase{{/uppercase}}
<h2>An image resized to 150px wide</h2>
<img src="{{#resize 150}}{{image}}{{/resize}}" />
{{#flags.myFlag.isSwitchedOn}}
The 'myFlag' flag is switched on
{{/flags.myFlag.isSwitchedOn}}
<time data-o-component="o-date" class="o-date" datetime="{{#dateformat}}{{date}}{{/dateformat}}">
{{#dateformat "dddd, d mmmm, yyyy"}}{{date}}{/dateformat}}
</time>
{{paragraphs text start=1 end=2}}
{{#removeImageTags}}
Image<img src="someimage.jpg" alt="This wont be shown"/>EndImage
{{/removeImageTags}}
</body>
</html>
Outputting date objects as strings
{{#dateformat}}{{ a date object }}{{/dateformat}}
outputs an isoString{{#dateformat "dddd, d mmmm, yyyy"}}{{ a date object }}{{/dateformat}}
outputs the date formatted as 'Tuesday, 3 February, 2014'Encoding strings to be output safely in html
{{encode q mode='uriComponent'}}
outputs the result of encodeURIComponent(q)
({{encode q }}
will also do this){{encode q mode='uri'}}
outputs the result of encodeURI(q)
Takes a topic identifier (currently something like topic:"European%20Cars"
) and converts to a next stream url /stream/topic/European%20Cars
{{topicUrl searchString}}
Outputting some paragraphs from a larger chunk of html, zero indexed
{{{paragraphs body start=0 end=1}}}
will output the first paragraph of body
. Note the triple mustachesStrips all image tags from a chunk of html
{{{removeImageTags body}}}
Note the triple mustachesOutputs contents if a thing is equal to a value
{{#ifEquals thing 'value'}} some content {{else}} some fallback content {{/ifEquals}}
Outputs contents if a number of things are truthy Note that handlebars has a slightly odd understanding of truthiness
{{#ifAll thing1 thing2 thing3}} some content {{else}} some fallback content {{/ifAll}}
FAQs
next-express [![Circle CI](https://circleci.com/gh/Financial-Times/next-express/tree/master.svg?style=svg)](https://circleci.com/gh/Financial-Times/next-express/tree/master) ============
The npm package ft-next-express receives a total of 3 weekly downloads. As such, ft-next-express popularity was classified as not popular.
We found that ft-next-express demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 7 open source maintainers 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
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.