This is a Javascript port of my HTML pre-processor that's to be used on the client side. It can be used to dynamically create complex DOM fragments.
For more information about SHP syntax check the original SHP repository.
- Install from the NPM
npm install @jakub21/shp
- Require the package to get the path to the bundled file
require('@jakub21/shp').path
- Use your server setup to serve the file
- Add a
<script>
tag in your HTML document with your chosen path
If you do not use Node.js you can download prebuilt shp.js
file from the releases tab. Add a <script>
tag that points to this file instead.
The recommended use is through Domi.js. See this section of readme for relevant information.
Package is contained within global shp
object. You can use the Compiler
class yourself for more control or utilize append
and prepend
aliases for clarity.
Compiles shp
and appends created nodes to element
.
Compiles shp
and prepends created nodes to element
.
Used to compile SHP code.
Returns an array of DOM nodes.
Resets internal state. Must be used between compile
calls.