![pnpm 10.0.0 Blocks Lifecycle Scripts by Default](https://cdn.sanity.io/images/cgdhsj6q/production/387e09b040c564e324704dac66871c6456fe5ded-1024x1024.png?w=400&fit=max&auto=format)
Security News
pnpm 10.0.0 Blocks Lifecycle Scripts by Default
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
angularjs-template-2
Advanced tools
Why do I need this? By unknown reason, I feel all server-side template engines are somewhat invasive. It looks like an odd language have been invaded HTML space. The only template I feel good about it is AngularJS, but it's all about client-side, not server-side part. If you are a big fan of AngularJS and you want to use AngularJS as a template engine, this node module will do the job.
This template converts the following one time binding expressions on the server-side;
inline expression
e.g. {{ foo }}
ht-if
attribute
e.g., <div ht-if="foo">..</div>
ht-repeat
attribute
e.g., <li ht-repeat="el in list">..</li>
e.g., <li ht-repeat="(k,v) in list">..</li>
ht-include attribute
e.g., <div ht-include="'file.html'"></div>
npm install angular-template
var htmlTemplate = require('angular-template');
htmlTemplate('{{foo}}', {foo:'Hello'}); //Hello
// or
var htmlTemplate = require('angular-template');
var path = "emails/template.html";
var options = {prefix:'ng'}; // so that ng-if, ng-repeat, ng-include would work
htmlTemplate(path, {name:'John'}, options);
prefix: <string>, override default ht prefix with anything, typically ng to reuse angular templates
preprocess: <function>, enables you to modify your template before parsing it as HTML. E.g. You can remove some attributes with RegExp
includeDirs: <array of string>, a list of paths where to look for template
cache: <string>, specify cache key to avoid reading files from disk every time
This will convert the angular-like expressions into html.
Assuming foo has the value of 123
Input | Output
-------------------------------------+---------------------------------
{{foo}} | 123
2. ht-if
attribute
Assuming foo has value true
, and bar has value false
Input | Output
-------------------------------------+---------------------------------
<p ht-if="foo">SHOW</p> | <p>SHOW</p>
<p ht-if="bar">NO SHOW</p> | <p></p>
3. ht-include
attribute
Assuming foo.html has the following contents <b>file contents</b>
The input and output would like;
Input | Output
-------------------------------------+------------------------------------
<p ht-include="'foo.html'"></p> | <p>
| <b>file contents</b>
| </p>
4. ht-repeat
attribute
Assuming collection has the vaulue of {a:1, b:2, c:3, d:4, e:5}
Input | Output
----------------------------------------------+------------------------------------
<ul> | <ul>
<li ht-repeat="(key, val) in collection"> | <li> a : 1</li>
{{key}} : {{val}} | <li> b : 2</li>
</li> | <li> c : 3</li>
</ul> | <li> d : 4</li>
| <li> e : 5</li>
| </ul>
Assuming collection has the vaulue of [1,2,3,4,5]
Input | Output
----------------------------------------------+------------------------------------
<ul> | <ul>
<li ht-repeat="num in collection"> | <li> 1 </li>
{{num}} | <li> 2 </li>
</li> | <li> 3 </li>
</ul> | <li> 4 </li>
| <li> 5 </li>
| </ul>
LICENSE: MIT
FAQs
Angular-Like HTML Template
The npm package angularjs-template-2 receives a total of 1 weekly downloads. As such, angularjs-template-2 popularity was classified as not popular.
We found that angularjs-template-2 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
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.