@ordergroove/smi-precompile
Advanced tools
Comparing version
{ | ||
"name": "@ordergroove/smi-precompile", | ||
"version": "1.0.1-0", | ||
"version": "1.1.0", | ||
"description": "Prcompilers for smi-core", | ||
@@ -8,10 +8,6 @@ "author": "Brian Lewis <brian.lewis@ordergroove.com>", | ||
"license": "ISC", | ||
"main": "index.js", | ||
"main": "precompile.js", | ||
"files": [ | ||
"lib" | ||
], | ||
"directories": { | ||
"lib": "lib", | ||
"test": "__tests__" | ||
}, | ||
"repository": { | ||
@@ -32,3 +28,4 @@ "type": "git", | ||
"lit-nunjucks": "^1.0.5" | ||
} | ||
}, | ||
"gitHead": "53fbd386c20b7e6bcf4414a621a6760a2bb54f74" | ||
} |
@@ -1,3 +0,6 @@ | ||
# `smi-templates` | ||
# `smi-precompile` | ||
Precompiles a liquid style template into smi function generator. | ||
Precompile returns code as string | ||
> Precompilers for smi-core | ||
@@ -7,5 +10,71 @@ | ||
```js | ||
resultCode = precompile(source, partials, locales, settings, (defaultLocale = 'en')); | ||
``` | ||
Example | ||
```js | ||
const precompile = require('@ordergroove/smi-precompile'); | ||
const result = precompile( | ||
` | ||
{% set some_value = 'yes' %} | ||
{% if some_value == ('some_setting' | setting) %} | ||
{% include 'some-include' %} | ||
{% endif %}`, | ||
{ | ||
'some-include.liquid': `{{ 'my_custom_text' | t }}` | ||
}, | ||
[ | ||
{ | ||
locale: 'en', | ||
translations: { my_custom_text: 'Hello world' } | ||
}, | ||
{ | ||
locale: 'es', | ||
translations: { my_custom_text: 'Hola mundo' } | ||
} | ||
], | ||
{ | ||
some_setting: 'yes' | ||
} | ||
); | ||
``` | ||
** outputs ** | ||
```js | ||
function template(html, repeat, unsafeHTML) { | ||
function template_en({}, _F) { | ||
var some_value; | ||
return html` | ||
${(() => { | ||
some_value = 'yes'; | ||
})()} ${some_value == 'yes' | ||
? html` | ||
Hello world | ||
` | ||
: ''} | ||
`; | ||
} | ||
function template_es({}, _F) { | ||
var some_value; | ||
return html` | ||
${(() => { | ||
some_value = 'yes'; | ||
})()} ${some_value == 'yes' | ||
? html` | ||
Hola mundo | ||
` | ||
: ''} | ||
`; | ||
} | ||
return { | ||
en: template_en, | ||
es: template_es | ||
}; | ||
} | ||
``` |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Empty package
Supply chain riskPackage does not contain any code. It may be removed, is name squatting, or the result of a faulty package publish.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
8884
864.6%4
100%141
Infinity%1
-50%80
627.27%