Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including squirrelly with all npm packages installed. Try it out:

var squirrelly = require("squirrelly")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

squirrelly v7.9.2

Simple and powerful template engine that supports helpers, partials, filters, native code, and Express.

Squirrel

squirrelly

Travis (.com) branch Codacy Badge JavaScript Style Guide Join the chat at https://gitter.im/squirrellyjs/Lobby Tip me at paypal.me/bengubler All Contributors

Summary

Squirrelly is a modern, configurable, and blazing fast template engine implemented in JavaScript. It works out of the box with ExpressJS and the full version weighs only ~2.2KB gzipped.

Notice: Squirrelly v8 was released in beta! Learn more about v8

All future development of Squirrelly 7 will be happening on the v7 branch.

Why Squirrelly?

Simply put, Squirrelly is super lightweight, super fast, simple, and gets the job done.

🌟 Features

  • :wrench: Custom helpers
  • :wrench: Custom filters
  • :package: 0 dependencies
  • :hammer: Conditionals
  • :zap: Exports ES Modules as well as UMD
  • :hammer: Loops
  • :wrench: Custom delimeters
  • :pencil2: Easy template syntax
  • :wrench: Precompilation
  • :hammer: Partials
  • :wrench: Inline JavaScript
  • :hammer: Comments
  • :wrench: Caching
  • :rocket: SUPER fast (look at the performance benchmarks here)

:scroll: Docs

We know nobody reads through the long and boring documentation in the ReadMe anyway, so head over to the documentation website:

:pencil: https://squirrelly.js.org

:notebook: Examples

Simple Template

var myTemplate = "<p>My favorite kind of cake is: {{favoriteCake}}</p>"

Sqrl.Render(myTemplate, {favoriteCake: 'Chocolate!'})
// Returns: '<p>My favorite kind of cake is: Chocolate!</p>

Conditionals

{{if(options.somevalue === 1)}}
Display this
{{#else}}
Display this
{{/if}}

Loops

{{each(options.somearray)}}
Display this
The current array element is {{@this}}
The current index is {{@index}}
{{/each}}

:heavy_check_mark: Tests

The default test can be run with npm test, and it just checks that compiling and rendering a simple template results in the correct string.

:handshake: Contributing

We love contributions from the community! Contributions are accepted using GitHub pull requests; for more information, see GitHub documentation - Creating a pull request.

For a good pull request, we ask you provide the following:

  1. Include a clear description of your pull request in the description with the basic "what" and "why" for the request.
  2. The test should pass.
  3. The pull request should include tests for the change. A new feature should have tests for the new feature and bug fixes should include a test that fails without the corresponding code change and passes after they are applied.
  4. If the pull request is a new feature, please include appropriate documentation in the README.md file as well.
  5. Keep a consistent coding style.

Contributors

Ben Gubler
Ben Gubler

💻 💬 📖 ⚠️
Mark Evans
Mark Evans

💻
donpedro
donpedro

💬

This project exists thanks to all the people who contribute. We welcome contributions! Learn how to contribute here.

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free