![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
pugjs is one popular js template engine formerly known as "Jade". It's indentation-sensitive with high-performance. But at some point, it could only run in nodejs (some version of "Jade" can run in browser), because from that point pugjs support APIs such as renderFile
which required I/O runtime.
npm i -S fib-pug
As of fs
module, luckily, fibjs has similar API with nodejs, we can run pugjs in fibjs, just do some magic hack with fibjs's sandbox
module.
const vm = require('vm');
const sbox = new vm.SandBox({
fs: require('fs'),
path: require('path'),
http: require('http'),
https: require('http'),
assert: require('assert'),
url: require('url'),
os: require('os'),
util: require('util')
});
// one valid pug module
const pug = sbox.require('pug', __filename)
as code above, just provide property module for orignal pug
module in nodejs, you can run pugjs in fibjs.
But I can't test all version of fibjs and pug, so I mark the tested version of fibjs and pug in package.json
and would notice developer if version when running this module in DEBUG mode.
I just support some API of pugjs, but I belive it's enough for your project in most cases.
compile
render
renderFile
view the parameters of this api in pugjs's page.
#!/usr/bin/env fibjs
const locals = {testVar: '测试变量'}
const rawText = 'div\n\t| #{testVar}'
try {
html = pug.compile(rawText, {pretty: true})(locals);
} catch (e) {
html = ''
error = e.message
}
console.log(html) // '<div>测试变量</div>'
If you don't know about this feature, learn more about it here
pug
takes jstransformer-*
-like packages(such as jstransformer-stylus) as default filter. That is, if you write :stylus
in pug, it would try to find jstransformer-stylus
in nodejs's common pattern.
Some jstransformer-*
-like packages may be incompatible with fibjs, You can also customize filter as you like. View more sample usages for filter here
FAQs
pug run in fibjs
The npm package fib-pug receives a total of 0 weekly downloads. As such, fib-pug popularity was classified as not popular.
We found that fib-pug 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
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.