npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

thistle

v0.0.3

Published

Customizable HTML template engine

Downloads

2

Readme

thistle - a slightly-prickly HTML template engine for NodeJS

Thistle is a HTML template engine for NodeJS that, unlike many other template systems, operates on a DOM-like structure rather than on raw strings.

DOM-based templating adds a little more overhead (which thistle attempts to minimize) but in return allows for more expressiveness via custom directives that allow for creating reusable template components and other reusable functionality.

Thistle is inspired by (but not entirely compatible with) AngularJS templates. Thistle attempts to provide much of the expressive power of AngularJS while optimizing for fast template rendering.

Basic Usage

Instantiate a thistle instance to begin:

var thistle = require('thistle');
var compiler = thistle();

By default the compiler has the basic, built-in directives and filters loaded. Templates using just these features can be compiled:

var render = compiler.compile('<ul>\n<li thi-repeat="item in items">{{ item }}</li>\n</ul>');

The compile method returns a function that takes a scope and returns a rendered DOM. A scope is just a plain old JavaScript object whose keys become variables for the template:

var nodes = render({items:['a', 'b', 'c']});

You'll usually want to render the resulting DOM as a string of HTML:

console.log(compiler.serializeHtml(nodes));

This basic example then results in the following output:

<ul>
<li>a</li><li>b</li><li>c</li>
</ul>

Most 'real' applications will compile all of the necessary templates once during startup and then render them many times with different data. Thus thistle is designed to do extra preparation work during compilation in order to enable faster rendering.

Status

Thistle is still under early development and thus its interface is still subject to change until a 1.0.0 release is reached. More implementation experience is required before we can confidently commit to an interface.

License

Copyright (c) 2014 Martin Atkins

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Contributing

Contributions are welcome via github pull requests. Please make sure the tests are passing (using npm test) and try to stick keep things consistent with the prevailing code style.

If you've tried to use Thistle in a real-world application and have design feedback, please consider opening a github issue describing your application and your suggestions.