Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
wagon-engine
Advanced tools
Readme
Wagon is a very fast and cool templating engine for fast development.
Here is quick example on the syntax.
<div id="myDiv">
{#if (usingWagon === true)}
{niceMessage()}
{:else}
Use it because it is cool.
{/if}
</div>
As you can see, it is literally javascript in html.
Now lets try to compile this template.
let renderer = Template.fromFile("fullPathToTemplate.html").compile();
console.log(
renderer({
usingWagon: true,
niceMessage: () => "Yay, you are using Wagon!",
})
);
Ouputs
<div id="myDiv">Yay, you are using Wagon!</div>
Time to spice things up!
with for loops...
{#for (let i = 0; i < 10; i ++>)}
{i}
{/for}
Outputs...
0 1 2 3 4 5 6 7 8 9
with while loops...
{#while (true)}
Oops no good
{/while}
Outputs...
Nothing just like any javascript never ending loop.
with literally javascript code...
{%
class Human {
constructor(name, age) {
this.name = name;
this.age = age;
}
greet() {
return `Hello, my name is ${this.name} and I am ${this.age}.`
}
}
}
{new Human("Bob", 20).greet()}
Outputs...
Hello, my name is Bob and I am 20
syntax | description | example |
---|---|---|
{code} | Evaluated and displayed | {"You will see me"} |
{% code} | Evaluated, but not displayed | {% let m = "You will not"} |
{# block statement} | Open a block statement | {# if (true)} |
{: block statement} | Chains a block statement | {: else if (true)} |
{/...} | Closes a block statement | {/ if} |
{@ code} | Evaluated during compile time | {@ this.include("./partial.html")} |
name | description |
---|---|
$main | Root template name (full path) |
$html | In generation HTML |
$code | Generated code |
data | Props passed from the renderer |
$html
can be modified by the template.
So...
{% $html += "Hello world"}
will be the same as...
{"Hello world"}
or even simpler...
Hello world
name | description |
---|---|
this.main | Root template name (full path) |
this.name | Current template name (full path) |
this.raw | Raw template |
this.code | In genration code |
this.vars | Render time variable names. eg. $html |
this.define(string name, any value) | Define a constant |
this.include(string relativePath) | Inserts compiled code from another template |
this.add(string code) | Inserts code during compile time |
There is syntax highlighter in the VScode Marketplace. https://marketplace.visualstudio.com/items?itemName=str1z.html-wagon-syntax-highlighting
FAQs
A very cool node HTML templating engine.
The npm package wagon-engine receives a total of 1 weekly downloads. As such, wagon-engine popularity was classified as not popular.
We found that wagon-engine 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.