templeo

1.0.0 • Public • Published

templeo

npm version Build Status Dependency Status Dev Dependency Status

Template Literals Engine

templeo is a 0️⃣ dependency template engine that uses built-in JavaScript/ECMAScript Template Literals. No Regular Expressions parsing or special syntax in templates here! Just 💯% built-in ES Template Literals!

For more details check out the tutorials and API docs!

Features

  • 💯% PURE
    No special syntax required! Everything is baked into the ECMAScript Template Literals specification itself! And since templeo/Template Literals are output-agnostic, a single Engine instance can output virtually any format (e.g. HTML, DOM Nodes, JSON, YAML, etc.).

  • 🌱 Grows with the language
    No need to update templeo when new features are added to the Template Literal spec. Any feature/syntax changes available within Template Literals are available for immediate use!

  • 🌐 Stand-Alone Rendering
    When a template is compiled into a rendering function it's no longer dependent upon templeo internals to render output - making rendering functions fully portable! Rendering functions can even be serverd from an HTTP server or any other source without any dependencies or references back to templeo!

  • 🛡️ Secure
    Since templeo does not have any special parsing syntax it does not suffer from syntax-specific injections. Compilation is also locally sandboxed to ensure that scope is isolated to global variable access (and require when available). Since rendering is stand-alone and portable, it is completely isolated from any scope other than the scope in which it is ran!

  • ⛓️ Parameterized/Nested Includes
    Fragments are reusable and can be included at compile-time and/or render-time using simple Tagged Template Literals. Also, supports passing parameters into included templates where the parameter scope is confined to the partial being included.

  • 🐞 Debugging
    Compiled templates are accessible directly via the VM sourceURL or through module imports/requires - allowing for seemless debugging capabilities.

  • 🧠 Extensible
    Template Literals naturally allow for any of your own helper functions to be accessible within the template literal itself as long as they are within scope of the templeo generated rendering function execution (or via registration). And since rendering functions are independent of templeo, included template content can evolve based upon a given context without having to be re-compiled!

  • 🛎️ Auto Fetch
    By default, template(s) and rendering context can be fetched/requested automatically at compile-time and/or render-time from an HTTP/S server. Also, render-time includes decouples the included template sources from the renderer allowing for newly dicovered template fragments to be included without re-compiling a new renderer!

  • 🏧 Caching
    By default, templates are cached in-memory for the duration of the Engine/template lifespan. There are a few other extensions that may be more suitable depending upon your needs.
    • IndexedDB (Browser) / LevelDB (Node.js)
      Recommended when templates need to be persistent between usage. Compiled templates are cached in either an IndexedDB store or a LevelDB store.
    • File System (Node.js)
      Recommended when running on the server. Compiled templates are cached within the file system and are loaded as modules so they can be debugged just like any other module. If template partials/fragments are used the corresponding files can be registered by providing a base directory to be scanned. The base directory can also be watched for changes that will automaticaly reregister partials with the updated partial content!

Package Sidebar

Install

npm i templeo

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

235 kB

Total Files

12

Last publish

Collaborators

  • ugate