
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
@hubot-friends/hubot-templating
Advanced tools
Javascript Server side templating engine with string literals
npm i @hubot-friends/hubot-templating
import path from 'node:path'
import { fileURLToPath } from 'node:url'
import { Template } from '@hubot-friends/hubot-templating'
const __dirname = fileURLToPath(new URL('.', import.meta.url))
const WWW_FOLDER = `${path.resolve(__dirname, './www')}/`
// files like layout files to be leveraged in templates.
const partials = new Map()
// some functions to be used int the templates
const functions = {
compare: (a, b)=> a == b,
current: (a, b)=> a.endsWith(b) ? ' current' : '',
difference: (posts, index)=> posts.length - index - 1,
format: (date, format)=> date.toLocaleDateString(undefined, format),
formatTime: (date, format)=> date.toLocaleTimeString(undefined, format),
formatDate: (date, format)=> date.toLocaleDateString(undefined, format),
}
for await (let file of files){
let data = await File.readFile(file, 'utf-8')
let key = file.replace(`${WWW_FOLDER}/`, '').replace(/[\s|\-]/g, '_')
if(key.indexOf('.html') > -1) {
partials.set(key, data)
}
}
const template = new Template('Some text with ${prop.content} in quotes', {prop: content = 'testing content'}, partials, functions)
const text = await template.render()
View index.test.mjs and test.html to see examples on how to create templates.
FAQs
Javascript Server side templating engine with string literals
The npm package @hubot-friends/hubot-templating receives a total of 1 weekly downloads. As such, @hubot-friends/hubot-templating popularity was classified as not popular.
We found that @hubot-friends/hubot-templating demonstrated a healthy version release cadence and project activity because the last version was released less than 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
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.