https://github.com/nice-digital/js2html
https://github.com/nice-digital/js2html
Last synced: 8 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/nice-digital/js2html
- Owner: nice-digital
- License: unlicense
- Created: 2015-09-18T08:18:20.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2018-03-02T11:41:02.000Z (over 8 years ago)
- Last Synced: 2025-09-20T04:40:40.346Z (9 months ago)
- Language: F#
- Size: 203 KB
- Stars: 0
- Watchers: 26
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
Process Json-Ld serializations into models and run through dotLiquid to generate HTML
##Example usage:
### Apply template 'test.html' to {'hello':'world'} and write to stdout
```
js2html --json "{'hello':'world'}" --template test.html
```
### Apply template 'page.html' to *.json in templatedir, writing .html files to /html
```
js2html --file *.json --templatedir /templates --output /html --template page.html
```
##Templating examples
Input Json-Ld.
~~~ .json
{
"@id": "http://ld.nice.org.uk/prov/entity#98ead3d:qualitystandards/qs70/st2/Statement.md",
"@type": ["prov:Entity", "owl:NamedIndividual"],
"qualitystandard:setting": "http://ld.nice.org.uk/ns/qualitystandard/setting#Primary care setting",
"qualitystandard:targetPopulation": ["http://ld.nice.org.uk/ns/qualitystandard/agegroup#Children 1-15 years", "http://ld.nice.org.uk/ns/qualitystandard/agegroup#Young people", "http://ld.nice.org.uk/ns/qualitystandard/conditiondisease#Urinary incontinence"],
"dcterms:abstract": "Children and young people have an agreed review date if they, or their\nparents or carers, are given advice about changing their daily routine\nto help with bedwetting.",
"dcterms:title": "Quality statement 2: Review after initial advice is given",
"prov:specializationOf": "resource:FF2ED3E529E5BDCDED86C24D3277F8A156814492DFE352A09804DF3228109D63",
"_id": "resource:FF2ED3E529E5BDCDED86C24D3277F8A156814492DFE352A09804DF3228109D63",
"_type": "qualitystatement"
}
---
Property names are transformed before injection into the template engine. '@' and ':' are removed so that it can render IRI properties. Property name access in dotLiquid is case insensitive, so you can use convention to indicate namespace - dcterms:Abstract can become dctermsAbstract.
##Example template
~~~ .html
{{@id}}
{{_id}}
{{qualitystandardSetting}}
{{dctermsAbstract}}
- {{item}}
{% for item in type -%}
{% endfor -%}
---
Applying this template to the sample Json-Ld produces
~~~ .html
parents or carers, are given advice about changing their daily routine
to help with bedwetting.
- prov:Entity
- owl:NamedIndividual
---