Project

mustachers

0.0
The project is in a healthy, maintained state
Mustache templating with Rust to test performance
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.1
~> 3.12
 Project Readme

Mustachers

Providing mustache rendering using Rust by wrapping the mustache crate.

At the moment only a simple render function taking a template file and parameters to interpolate. This does not look to replace or compete with the ruby offering, but provides an alternative seemingly offering a performance enhancement.

Installation

Install the gem and add to the application's Gemfile by executing:

$ bundle add mustachers

If bundler is not being used to manage dependencies, install the gem by executing:

$ gem install mustachers

Usage

Require the gem if needed. Some might be dynamically loaded.

require 'mustachers'

An example of using the gem.

Mustachers::Renderer.render("<h1>{{text}}</h1>", {text: "abc123"})

From the console.

bundle exec ruby -r mustachers -e 'puts Mustachers::Renderer.render("<h1>{{text}}</h1>", {text: "abc123"})'
<h1>abc123</h1>

Benchmark

The script for this can be found in the benchmarks directory.

bundle exec ruby benchmarks/simple.rb
       user     system      total        real
 236.928979   1.059659 237.988638 (239.572824) # ruby
  13.929279   0.069823  13.999102 ( 14.088116) # rust

Development

TODO:

  • Check Ruby performance such as any memory leaks and garbage collection.
  • Improve the error handling to raise an appropriate error.
  • Unit tests in rust to provide faster feedback while developing.
  • More options for the template rendering such as reading the file.
  • Benchmarking with different sized inputs.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/samfrench/mustachers.