Rust templating with Handlebars

Overview

handlebars-rust

Handlebars templating language implemented in Rust and for Rust.

Handlebars-rust is the template engine that renders the official Rust website rust-lang.org, its book.

Build Status MIT licensed Docs rustc Donate

Getting Started

Quick Start

extern crate handlebars;
#[macro_use]
extern crate serde_json;

use handlebars::Handlebars;

fn main() -> Result<(), Box<dyn Error>> {
    let mut reg = Handlebars::new();
    // render without register
    println!(
        "{}",
        reg.render_template("Hello {{name}}", &json!({"name": "foo"}))?
    );

    // register template using given name
    reg.register_template_string("tpl_1", "Good afternoon, {{name}}")?;
    println!("{}", reg.render("tpl_1", &json!({"name": "foo"}))?);
    Ok(())
}

Code Example

If you are not familiar with handlebars language syntax, it is recommended to walk through their introduction first.

Examples are provided in source tree to demo usage of various api.

  • quick the very basic example of registry and render apis
  • render how to define custom helpers with function, trait impl or macro, and also how to use custom helpers.
  • render_file similar to render, but render to file instead of string
  • partials template inheritance with handlebars
  • decorator how to use decorator to change data or define custom helper
  • script how to define custom helper with rhai scripting language, just like using javascript for handlebarsjs
  • error simple case for error
  • dev_mode a web server hosts handlebars in dev_mode, you can edit the template and see the change without restarting your server.

Minimum Rust Version Policy

Handlebars will track Rust nightly and stable channel. When dropping support for previous stable versions, I will bump major version and clarify in CHANGELOG.

Rust compatibility table

Handlebars version range Minimum Rust version
~3.0.0 1.32
~2.0.0 1.32
~1.1.0 1.30
~1.0.0 1.23

Document

Rust doc.

Changelog

Changelog is available in the source tree named as CHANGELOG.md.

Contributor Guide

Any contribution to this library is welcomed. To get started into development, I have several Help Wanted issues, with the difficulty level labeled. When running into any problem, feel free to contact me on github.

I'm always looking for maintainers to work together on this library, let me know (via email or anywhere in the issue tracker) if you want to join.

Why (this) Handlebars?

Handlebars is a real-world templating system that you can use to build your application without pain.

Features

Isolation of Rust and HTML

This library doesn't attempt to use some macro magic to allow you to write your template within your rust code. I admit that it's fun to do that but it doesn't fit real-world use cases.

Limited but essential control structures built-in

Only essential control directives if and each are built-in. This prevents you from putting too much application logic into your template.

Extensible helper system

You can write your own helper with Rust! It can be a block helper or inline helper. Put your logic into the helper and don't repeat yourself.

A helper can be as a simple as a Rust function like:

handlebars_helper!(hex: |v: i64| format!("0x{:x}", v));

/// register the helper
handlebars.register_helper("hex", Box::new(hex));

And using it in your template:

{{hex 16}}

By default, handlebars-rust ships additional helpers (compared with original js version) that is useful when working with if.

With script_helper feature flag enabled, you can also create helpers using rhai script, just like JavaScript for handlebars-js. This feature was in early stage. Its API was limited at the moment, and can change in future.

Template inheritance

Every time I look into a templating system, I will investigate its support for template inheritance.

Template include is not sufficient for template reuse. In most cases you will need a skeleton of page as parent (header, footer, etc.), and embed your page into this parent.

You can find a real example of template inheritance in examples/partials.rs and templates used by this file.

Auto-reload in dev mode

By turning on dev_mode, handlebars auto reloads any template and scripts that loaded from files or directory. This can be handy for template development.

WebAssembly compatible

Handlebars 3.0 can be used in WebAssembly projects.

Related Projects

Web frameworks

Adopters

The adopters page lists projects that uses handlebars for part of their functionalities.

Extensions

The extensions page has libraries that provide additional helpers, decorators and outputs to handlebars-rust, and you can use in your own projects.

License

This library (handlebars-rust) is open sourced under the MIT License.

Comments
  • Pest parser

    Pest parser

    Fixes #81

    I decided to use pest to replace current custom parser for maintainability and correctness.

    Tasks:

    • [x] Grammar
    • [x] Rebuild parser with pest Rdp.queue() results
    • [x] Keeping error tracking: report template error with line/column number
    • [x] Keeping template element maps, line/column number for each item
    • [x] Retain leading whitespaces in text
    opened by sunng87 21
  • added a markdown helper

    added a markdown helper

    I know this is probably just the beginning but I think I added a working markdown helper so that if you have a variable x that is a string containing markdown, then you can parse it to html by passing

    {{markdown x}}
    

    in the template..

    I want to improve this by adding some kind of environment, but I couldn't quite figure it out right away (and the use case above is the one that i want to use anyway). As a second commit perhaps something like below could be implemented

    {{#markdown}}
    #wow
    {{> sub_template}}
    {{~markdown}}
    

    edit: also sorry that this changed Cargo.toml so much. I used cargo add pulldown-cmark and it must have mangled the Cargo.toml I will go back and edit by hand

    opened by waynenilsen 18
  • Segfault in Handlebars

    Segfault in Handlebars

    I just experienced a segfault which seems to be originated in the handlebars code.

    As there are ~6000 stack levels, it seems that I ended up crashing into the heap by recursing too deep. The recursion seems to happen in handlebars, as only a few (as in below 10) stack levels are from my code.

    The corrosponding code is here, here is the causing call.

    The templates can be found here, the registration of the templates and the helpers is here. If you have any questions regarding the code, feel free to ask me, I know the codebase is pretty big and maybe confusing for some people.


    To reproduce:

    • Clone the repository, checkout the branch from the PR
    • cargo build --manifest-path bin/core/imag-store/Cargo.toml # takes some time
    • mkdir /tmp/store/
    • ./target/debug/imag-store --rtp /tmp/ --config imagrc.toml create -p test entry -c foo
    • enjoy.

    The last few lines of the stacktrace follow


    #6274 0x00005555556808c2 in core::result::Result<&handlebars::template::Template, handlebars::error::RenderError>::and_then<&handlebars::template::Template,handlebars::error::RenderError,(),closure> (self=Ok = {...}, op=closure = {...})
        at /build/rustc-1.17.0-src/src/libcore/result.rs:601
    #6275 0x00005555555f8b18 in handlebars::registry::Registry::renderw<collections::btree::map::BTreeMap<&str, collections::string::String>> (self=0x7ffff6ab9038, name="DEBUG", data=0x7fffffff5578, writer=&mut Write)
        at /home/m/.cargo/registry/src/github.com-1ecc6299db9ec823/handlebars-0.29.0/src/registry.rs:247
    #6276 0x00005555555f8654 in handlebars::registry::Registry::render<collections::btree::map::BTreeMap<&str, collections::string::String>> (self=0x7ffff6ab9038, name="DEBUG", data=0x7fffffff5578)
        at /home/m/.cargo/registry/src/github.com-1ecc6299db9ec823/handlebars-0.29.0/src/registry.rs:236
    #6277 0x00005555556f75c4 in libimagrt::logger::{{impl}}::log (self=0x7ffff6ab9000, record=0x7fffffff5a50) at /home/m/archive/development/rust/imag/lib/core/libimagrt/src/logger.rs:149
    #6278 0x0000555555e16a17 in log::__log (level=log::LogLevel::Debug, target="handlebars::render", loc=0x5555562f06a8 <<handlebars::template::TemplateElement as handlebars::render::Renderable>::render::_LOC>, args=Arguments = {...})
        at /home/m/.cargo/registry/src/github.com-1ecc6299db9ec823/log-0.3.8/src/lib.rs:903
    #6279 0x0000555555ae6784 in handlebars::render::{{impl}}::render (self=0x7ffff6a35400, registry=0x7ffff6ab9038, rc=0x7fffffff7038) at /home/m/.cargo/registry/src/github.com-1ecc6299db9ec823/handlebars-0.29.0/src/render.rs:641
    #6280 0x0000555555ae5e41 in handlebars::render::{{impl}}::render (self=0x7ffff6a37718, registry=0x7ffff6ab9038, rc=0x7fffffff7038) at /home/m/.cargo/registry/src/github.com-1ecc6299db9ec823/handlebars-0.29.0/src/render.rs:590
    #6281 0x00005555555f8f6e in handlebars::registry::{{impl}}::renderw::{{closure}}<collections::btree::map::BTreeMap<&str, collections::string::String>> (t=0x7ffff6a37718) at /home/m/.cargo/registry/src/github.com-1ecc6299db9ec823/handlebars-0.29.0/src/registry.rs:254
    #6282 0x00005555556808c2 in core::result::Result<&handlebars::template::Template, handlebars::error::RenderError>::and_then<&handlebars::template::Template,handlebars::error::RenderError,(),closure> (self=Ok = {...}, op=closure = {...})
        at /build/rustc-1.17.0-src/src/libcore/result.rs:601
    #6283 0x00005555555f8b18 in handlebars::registry::Registry::renderw<collections::btree::map::BTreeMap<&str, collections::string::String>> (self=0x7ffff6ab9038, name="DEBUG", data=0x7fffffff79d8, writer=&mut Write)
        at /home/m/.cargo/registry/src/github.com-1ecc6299db9ec823/handlebars-0.29.0/src/registry.rs:247
    #6284 0x00005555555f8654 in handlebars::registry::Registry::render<collections::btree::map::BTreeMap<&str, collections::string::String>> (self=0x7ffff6ab9038, name="DEBUG", data=0x7fffffff79d8)
        at /home/m/.cargo/registry/src/github.com-1ecc6299db9ec823/handlebars-0.29.0/src/registry.rs:236
    #6285 0x00005555556f75c4 in libimagrt::logger::{{impl}}::log (self=0x7ffff6ab9000, record=0x7fffffff7eb0) at /home/m/archive/development/rust/imag/lib/core/libimagrt/src/logger.rs:149
    #6286 0x0000555555e16a17 in log::__log (level=log::LogLevel::Debug, target="handlebars::render", loc=0x5555562f06a8 <<handlebars::template::TemplateElement as handlebars::render::Renderable>::render::_LOC>, args=Arguments = {...})
        at /home/m/.cargo/registry/src/github.com-1ecc6299db9ec823/log-0.3.8/src/lib.rs:903
    #6287 0x0000555555ae6784 in handlebars::render::{{impl}}::render (self=0x7ffff6a35400, registry=0x7ffff6ab9038, rc=0x7fffffff9498) at /home/m/.cargo/registry/src/github.com-1ecc6299db9ec823/handlebars-0.29.0/src/render.rs:641
    #6288 0x0000555555ae5e41 in handlebars::render::{{impl}}::render (self=0x7ffff6a37718, registry=0x7ffff6ab9038, rc=0x7fffffff9498) at /home/m/.cargo/registry/src/github.com-1ecc6299db9ec823/handlebars-0.29.0/src/render.rs:590
    #6289 0x00005555555f8f6e in handlebars::registry::{{impl}}::renderw::{{closure}}<collections::btree::map::BTreeMap<&str, collections::string::String>> (t=0x7ffff6a37718) at /home/m/.cargo/registry/src/github.com-1ecc6299db9ec823/handlebars-0.29.0/src/registry.rs:254
    #6290 0x00005555556808c2 in core::result::Result<&handlebars::template::Template, handlebars::error::RenderError>::and_then<&handlebars::template::Template,handlebars::error::RenderError,(),closure> (self=Ok = {...}, op=closure = {...})
        at /build/rustc-1.17.0-src/src/libcore/result.rs:601
    #6291 0x00005555555f8b18 in handlebars::registry::Registry::renderw<collections::btree::map::BTreeMap<&str, collections::string::String>> (self=0x7ffff6ab9038, name="DEBUG", data=0x7fffffff9e38, writer=&mut Write)
        at /home/m/.cargo/registry/src/github.com-1ecc6299db9ec823/handlebars-0.29.0/src/registry.rs:247
    ---Type <return> to continue, or q <return> to quit---
    #6292 0x00005555555f8654 in handlebars::registry::Registry::render<collections::btree::map::BTreeMap<&str, collections::string::String>> (self=0x7ffff6ab9038, name="DEBUG", data=0x7fffffff9e38)
        at /home/m/.cargo/registry/src/github.com-1ecc6299db9ec823/handlebars-0.29.0/src/registry.rs:236
    #6293 0x00005555556f75c4 in libimagrt::logger::{{impl}}::log (self=0x7ffff6ab9000, record=0x7fffffffa310) at /home/m/archive/development/rust/imag/lib/core/libimagrt/src/logger.rs:149
    
    #6294 0x0000555555e16a17 in log::__log (level=log::LogLevel::Debug, target="libimagrt::runtime", loc=0x5555562e92f0 <libimagrt::runtime::Runtime::_new::_LOC>, args=Arguments = {...}) at /home/m/.cargo/registry/src/github.com-1ecc6299db9ec823/log-0.3.8/src/lib.rs:903
    #6295 0x00005555555d4d34 in libimagrt::runtime::Runtime::_new<clap::app::App> (cli_app=App = {...}, matches=ArgMatches = {...}, Python Exception <type 'exceptions.ValueError'> invalid literal for int() with base 0: '0x1 <error: Cannot access memory at address 0x1>': 
    config=...) at <log macros>:7
    #6296 0x00005555555d4319 in libimagrt::runtime::Runtime::new<clap::app::App> (cli_app=App = {...}) at /home/m/archive/development/rust/imag/lib/core/libimagrt/src/runtime.rs:97
    #6297 0x00005555555d360d in libimagrt::setup::generate_runtime_setup<fn(clap::app::App) -> clap::app::App> (name="imag-store", version="0.4.0", about="Direct interface to the store. Use with great care!", builder=0x0)
        at /home/m/archive/development/rust/imag/lib/core/libimagrt/src/setup.rs:39
    #6298 0x00005555555e642c in imag_store::main () at /home/m/archive/development/rust/imag/bin/core/imag-store/src/main.rs:71
    
    opened by matthiasbeyer 14
  • update some debs for minimal-versions

    update some debs for minimal-versions

    This bumps the minimal acceptable versions in Cargo.toml to versions that are compatible with -Z minimal-versions. This is part of the process of seeing how hard this is for crates to use in preparation for getting it stabilized for use in CI, specifically upstreaming the changes required to get criterion working with it. It is easy to use if all of your dependencies support it, but much harder if trying to impose it on them.

    Also cargo defaults to interpreting version requirements as ^. So this switched to the shorter form.

    opened by Eh2406 12
  • Consider using rustc_serialize::json::encode to obtain json

    Consider using rustc_serialize::json::encode to obtain json

    Rather than force every structure to implement the ToJson trait, it might be preferable to allow users to just add a #[derive(RustcEncodable)] on their structs, and handlebars can obtain a JSON value via the rustc_serialize::json::encode function.

    opened by hugoduncan 12
  • handlebars 3.2.0 breaks existing code

    handlebars 3.2.0 breaks existing code

    Presumably because of #346 but haven't confirmed yet.

    This custom helper https://github.com/CleverCloud/amq-protocol/blob/011ed7a80d4448b03ca2db48b50e73c03104b98d/codegen/src/templating.rs#L283-L343 now hits this assertion with 3.2.0 while it works fine with 3.1.0 https://github.com/CleverCloud/amq-protocol/blob/011ed7a80d4448b03ca2db48b50e73c03104b98d/codegen/src/templating.rs#L307

    bug 
    opened by Keruspe 11
  • signle quote not working

    signle quote not working

    Test:

        #[test]
        fn test_template() {
            let mut handlebars = Handlebars::new();
            let data = json!({});
            handlebars.render_template("{{'test'}}", &data).unwrap();
        }
    

    Throw,

    ---- test::test_template stdout ----
    thread 'test::test_template' panicked at 'called `Result::unwrap()` on an `Err` value: RenderError { desc: "Failed to parse template.", template_name: None, line_no: None, column_no: None, cause: Some(TemplateError { reason: InvalidSyntax, template_name: None, line_no: Some(1), column_no: Some(3), segment: Some("   0 | {{'test'}}\n     |---^------\n") }), unimplemented: false }', src/main.rs:155:57
    note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
    
    opened by theowenyoung 10
  • Compile error with the 2.0.3 update

    Compile error with the 2.0.3 update

    Hi! I use the mdbook crate and it stopped compiling today, very likely due to handlebars' update.

    I don't know much about both projects but here's the error:

    Error
    Compiling mdbook v0.3.5
    error[E0277]: `(dyn std::error::Error + 'static)` cannot be sent between threads safely
    --> /home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/mdbook-0.3.5/src/lib.rs:123:5
        |
    123 | /     error_chain! {
    124 | |         foreign_links {
    125 | |             Io(std::io::Error) #[doc = "A wrapper around `std::io::Error`"];
    126 | |             HandlebarsRender(handlebars::RenderError) #[doc = "Handlebars rendering failed"];
    ...   |
    156 | |         }
    157 | |     }
        | |_____^ `(dyn std::error::Error + 'static)` cannot be sent between threads safely
        |
        = help: the trait `std::marker::Send` is not implemented for `(dyn std::error::Error + 'static)`
        = note: required because of the requirements on the impl of `std::marker::Send` for `std::ptr::Unique<(dyn std::error::Error + 'static)>`
        = note: required because it appears within the type `std::boxed::Box<(dyn std::error::Error + 'static)>`
        = note: required because it appears within the type `std::option::Option<std::boxed::Box<(dyn std::error::Error + 'static)>>`
        = note: required because it appears within the type `handlebars::error::RenderError`
        = note: required because it appears within the type `errors::ErrorKind`
        = note: required because it appears within the type `errors::Error`
        = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
    

    Since the update was a patch, the issue is more to report the breaking change than anything else.

    Here's the issue in mdbook.

    opened by leudz 10
  • Iterate through JSON Object that has keys with unusual characters

    Iterate through JSON Object that has keys with unusual characters

    Hello! First off, thanks for all the great work!

    I'm trying to render a Handlebars template that needs to iterate through a JSON object with keys that contain dots and spaces. This causes Handlebars to return a RenderError with description Invalid JSON path.

    Minimal Example

    It fails in the same way if I replace "strange key" with "strange.key". I tried this using handlebars-rust version 0.28.3.

    extern crate handlebars;
    #[macro_use]
    extern crate serde_json;
    
    use handlebars::Handlebars;
    
    fn main() {
        Handlebars::new().template_render(
            "{{#each x}} {{@key}} {{this}}, {{/each}}",
            &json!({"x": {"a": 1, "b": 2, "strange key": 3}})
        ).map(|s| println!("{}", s)).unwrap();
    }
    

    Handlebars Code

    I believe this line in src/grammar.rs in today's master branch is relevant:

    path_ident = _{ ['a'..'z']|['A'..'Z']|['0'..'9']|["_"]|["@"]|["$"]|["<"]|[">"]|["-"]}
    

    I'm unfamiliar with Handlebars, but this grammar could be updated to support more general JSON keys, or it could be ignored if referring to the key using this or @key.

    I'd be glad to submit a PR if necessary, but I would appreciate any help.

    opened by roguh 10
  • Partial is rendered twice

    Partial is rendered twice

    Not sure if this is an issue with the library or my syntax. I'm updating a project that I wrote from the legacy partial syntax to the new syntax. I have three (simplified) templates like this:

    <!-- base.hbs -->
    <html>
    <body>
    {{> layout}}
    </body>
    </html>
    
    <!-- blog.hbs -->
    {{#> base}}
    
    {{#*inline "layout"}}
    <div>
    {{#> content}}
    Parent content
    {{> otherHelper}}
    {{/content}}
    </div>
    {{/inline}}
    
    {{/base}}
    
    <!-- blog_post.hbs -->
    {{#> blog}}
    
    {{#*inline "content"}}
    Child content
    {{/inline}}
    
    {{/blog}}
    

    The problem is that the otherHelper helper gets rendered (and output) twice, and I cannot figure out why.

    bug 
    opened by euclio 10
  • Enum handling

    Enum handling

    If I had an enum like:

    pub enum Value {
        Float(f64),
        Bool(bool),
    }
    

    How would I render something like:

    {{#if value == Float(val)}}
        <input type='number' value={{val}} />
    {{/if}}
    
    {{#if value == Bool(val)}}
        <input type='checkbox' checked={{val}} />
    {{/if}}
    
    opened by ghotiphud 10
  • chore(deps): bump ssri from 6.0.1 to 6.0.2 in /playground/www

    chore(deps): bump ssri from 6.0.1 to 6.0.2 in /playground/www

    Bumps ssri from 6.0.1 to 6.0.2.

    Changelog

    Sourced from ssri's changelog.

    6.0.2 (2021-04-07)

    Bug Fixes

    • backport regex change from 8.0.1 (b30dfdb), closes #19

    Commits
    Maintainer changes

    This version was pushed to npm by nlf, a new releaser for ssri since your current version.


    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) You can disable automated security fix PRs for this repo from the Security Alerts page.
    dependencies javascript 
    opened by dependabot[bot] 1
  • chore(deps): bump json5 and copy-webpack-plugin in /playground/www

    chore(deps): bump json5 and copy-webpack-plugin in /playground/www

    Removes json5. It's no longer used after updating ancestor dependency copy-webpack-plugin. These dependencies need to be updated together.

    Removes json5

    Updates copy-webpack-plugin from 5.1.1 to 11.0.0

    Release notes

    Sourced from copy-webpack-plugin's releases.

    v11.0.0

    11.0.0 (2022-05-17)

    ⚠ BREAKING CHANGES

    • minimum supported Node.js version is 14.15.0

    v10.2.4

    10.2.4 (2022-01-31)

    Bug Fixes

    v10.2.3

    10.2.3 (2022-01-29)

    Bug Fixes

    v10.2.2

    10.2.2 (2022-01-28)

    Bug Fixes

    v10.2.1

    10.2.1 (2022-01-20)

    Bug Fixes

    v10.2.0

    10.2.0 (2021-12-16)

    Features

    • removed cjs wrapper and generated types in commonjs format (export = and namespaces used in types), now you can directly use exported types (#654) (5901006)

    v10.1.0

    10.1.0 (2021-12-10)

    ... (truncated)

    Changelog

    Sourced from copy-webpack-plugin's changelog.

    11.0.0 (2022-05-17)

    ⚠ BREAKING CHANGES

    • minimum supported Node.js version is 14.15.0

    build

    10.2.4 (2022-01-31)

    Bug Fixes

    10.2.3 (2022-01-29)

    Bug Fixes

    10.2.2 (2022-01-28)

    Bug Fixes

    10.2.1 (2022-01-20)

    Bug Fixes

    10.2.0 (2021-12-16)

    Features

    • removed cjs wrapper and generated types in commonjs format (export = and namespaces used in types), now you can directly use exported types (#654) (5901006)

    10.1.0 (2021-12-10)

    Features

    ... (truncated)

    Commits

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) You can disable automated security fix PRs for this repo from the Security Alerts page.
    dependencies javascript 
    opened by dependabot[bot] 1
  • chore(deps): bump serialize-javascript from 2.1.2 to 6.0.0 in /playground/www

    chore(deps): bump serialize-javascript from 2.1.2 to 6.0.0 in /playground/www

    Bumps serialize-javascript from 2.1.2 to 6.0.0.

    Release notes

    Sourced from serialize-javascript's releases.

    v6.0.0

    Changelog

    • Add support for URL's (#123)
    • Bump mocha from 9.0.0 to 9.0.1 (#124)
    • Bump mocha from 8.4.0 to 9.0.0 (#121)
    • Update Node.js CI matrix (#122)
    • Bump mocha from 8.3.2 to 8.4.0 (#120)
    • Bump lodash from 4.17.19 to 4.17.21 (#119)
    • Bump y18n from 4.0.0 to 4.0.1 (#116)
    • Bump chai from 4.3.3 to 4.3.4 (#115)
    • Bump mocha from 8.3.1 to 8.3.2 (#114)
    • Bump mocha from 8.3.0 to 8.3.1 (#113)
    • Bump chai from 4.3.1 to 4.3.3 (#112)
    • Bump chai from 4.2.0 to 4.3.1 (#111)
    • Bump mocha from 8.2.1 to 8.3.0 (#109)
    • Bump mocha from 8.1.3 to 8.2.1 (#105)
    • Drop Travis CI settings (#100)
    • Change default branch name to main (#99)
    • GitHub Aactions (#98)

    Behavior changes for URL objects

    It serializes URL objects as follows since this version. The result of serialization may be changed if you are passing URL object values into the serialize-javascript.

    const serialize = require("serialize-javascript");
    

    serialize({u: new URL("http://example.com/&quot;)}); // '{"u":new URL("http://example.com/&quot;)}'


    Thank you @​rrdelaney for this release.

    v5.0.1

    Changelog

    • Exclude .vscode and .github directories from package (#97)

    v5.0.0

    Changelog

    • Bump mocha from 8.1.2 to 8.1.3 (#96)
    • Support sparse arrays (#95)
    • Bump mocha from 8.1.1 to 8.1.2 (#94)
    • Bump mocha from 8.1.0 to 8.1.1 (#92)
    • Create Dependabot config file (#91)
    • Bump mocha from 8.0.1 to 8.1.0 (#90)
    • Bump lodash from 4.17.15 to 4.17.19 (#89)
    • Bump mocha from 7.2.0 to 8.0.1 (#88)

    Behavior changes for sparse arrays

    ... (truncated)

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) You can disable automated security fix PRs for this repo from the Security Alerts page.
    dependencies javascript 
    opened by dependabot[bot] 1
  • chore(deps): bump y18n from 4.0.0 to 4.0.3 in /playground/www

    chore(deps): bump y18n from 4.0.0 to 4.0.3 in /playground/www

    Bumps y18n from 4.0.0 to 4.0.3.

    Changelog

    Sourced from y18n's changelog.

    4.0.3 (2021-04-07)

    Bug Fixes

    • release: 4.x.x should not enforce Node 10 (#126) (1e21a53)

    4.0.1 (2020-11-30)

    Bug Fixes

    Commits
    Maintainer changes

    This version was pushed to npm by oss-bot, a new releaser for y18n since your current version.


    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) You can disable automated security fix PRs for this repo from the Security Alerts page.
    dependencies javascript 
    opened by dependabot[bot] 1
  • chore(deps): bump kind-of from 6.0.2 to 6.0.3 in /playground/www

    chore(deps): bump kind-of from 6.0.2 to 6.0.3 in /playground/www

    Bumps kind-of from 6.0.2 to 6.0.3.

    Changelog

    Sourced from kind-of's changelog.

    [6.0.3] - 2020-01-16

    • Merge pull request #31 for issue #30

    [6.0.0] - 2017-10-13

    • refactor code to be more performant
    • refactor benchmarks

    [5.1.0] - 2017-10-13

    Added

    • Merge pull request #15 from aretecode/patch-1
    • adds support and tests for string & array iterators

    Changed

    • updates benchmarks

    [5.0.2] - 2017-08-02

    • Merge pull request #14 from struct78/master
    • Added undefined check

    [5.0.0] - 2017-06-21

    • Merge pull request #12 from aretecode/iterator
    • Set Iterator + Map Iterator
    • streamline isbuffer, minor edits

    [4.0.0] - 2017-05-19

    • Merge pull request #8 from tunnckoCore/master
    • update deps

    [3.2.2] - 2017-05-16

    • fix version

    [3.2.1] - 2017-05-16

    • add browserify

    [3.2.0] - 2017-04-25

    • Merge pull request #10 from ksheedlo/unrequire-buffer
    • add promise support and tests
    • Remove unnecessary Buffer check

    ... (truncated)

    Commits
    Maintainer changes

    This version was pushed to npm by doowb, a new releaser for kind-of since your current version.


    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) You can disable automated security fix PRs for this repo from the Security Alerts page.
    dependencies javascript 
    opened by dependabot[bot] 1
  • How to use square brackets when calling helper?

    How to use square brackets when calling helper?

    I can't figure out how to use square brackets to refer to a helper. While fuzzing, a template like {{[\0] ''}} failed and said there was no helper named \0 even though it was defined. However, when I used the same template and defined a helper named [\0], it worked.

    Naming the helper \0 works in the Handlebars.js playground but naming it [\0] doesn't, so I'm not sure why the opposite is true for handlebars-rust.

    Question

    What am I doing wrong? I used handlebars.register_helper to register the helper. Is it supposed to be done some other way?

    opened by ysthakur 0
Releases(v4.3.6)
  • v4.3.6(Dec 31, 2022)

  • v4.3.0(May 18, 2022)

    Changes included in 4.3.0 release:

    • [Changed] update MSRV to 1.57 as rhai requires
    • [Fixed] Reimplemented indent support for partial expression {{> partial}}, which is introduced in 4.2.0. The new implementation is aligned with original javascript version, that every text line generated from partial are indented as {{> partial}} does. prevent_indent will turn-off this feature. [#505]
    • [Changed] changed error support library from quick_error to thiserror

    Caution that the partial indent fix will make handlebars 4.3 behaviour different with 4.2 when there is indent with {{> partial}} statement.

    Source code(tar.gz)
    Source code(zip)
  • v4.2.1(Feb 3, 2022)

  • v4.2.0(Jan 6, 2022)

    Added

    • RustEmbed support for loading templates from [#484]

    Fixed

    • Parser support for variables begins with digit [#479]
    • Typo in Debug impl of Handlebars [#485 ]

    Changed

    • Keep indent whitespaces for partial expression {{> partial}} as default in handlebarsjs. A new option prevent_indent is provided on Handlebars to turn off this behaviour. [#486]
    • Update MSRV to 1.51 due to dependency changes
    Source code(tar.gz)
    Source code(zip)
  • v4.1.5(Nov 18, 2021)

  • v4.1.4(Nov 5, 2021)

  • v4.1.3(Sep 13, 2021)

  • v4.1.2(Aug 22, 2021)

    Added

    • Support for generic types in handlebars_helper!.
    • Getter and setter for rhai Engine from registry.

    Fixed

    • Improve doc for dev_mode that it has to be enabled before adding templates.
    Source code(tar.gz)
    Source code(zip)
  • v4.1.1(Jul 31, 2021)

  • v4.1.0(Jul 12, 2021)

    Detailed Changelog

    • [Added] export StringOutput as requested in #442
    • [Changed] strict mode now applies to our helper macro handlebars_helper! and built-in helpers based on it.
    • [Fixed] Line stripping feature for standalone statement introduced in #404 is now aligned with handlebarsjs. #448
    Source code(tar.gz)
    Source code(zip)
  • v4.0.0(May 25, 2021)

    4.0 Highlights

    Development mode

    4.0 brings in dev_mode to Handlebars. By turning on dev_mode, templates loaded from files or directories are auto-reloaded each time. This makes development workflow more fluent.

    Performance improvement

    4.0 provides up to 20% performance boost compared to 3.x.

    Bugfixes

    Several corner cases were fixed in this release. Some has already been backported on to 3.x branch.

    Detailed Changelog

    • [Added] dev_mode for registry: templates and scripts loaded from file are always reloaded when dev mode enabled [#395]
    • [Added] Registry is now Clone [#395]
    • [Added] New built-in helper len [#421]
    • [Changed] Updated rhai to 0.19 and then 0.20 [#391]
    • [Changed] #each helper now renders else block for non-iterable data [#380]
    • [Changed] TemplateError and ScriptError is now a cause of RenderError [#395]
    • [Changed] Empty lines around block helpers are now stripped [#404]
    • [Changed] Breaking RenderContext::get_partial now returns Option<&Template>
    • [Changed] Breaking Capitalize names like HtmlExpression and IoError based on clippy recommendations [#424]
    • [Changed] Breaking Improved return type of call_inner from HelperDef to avoid misleading [#437]
    • [Fixed] reference starts with null, true and false were parsed incorrectly [#382]
    • [Fixed] dir source path separator bug on windows [#389] [#405]
    • [Fixed] stack overflow with nested @partial-block [#401]
    • [Fixed] value access issue when upper block has a base value [#419]
    • [Fixed] escape rules for Json string literal [#423]
    • [Fixed] Breaking zero-arity subexpressions support [#433] Zero-arity subexpression no longer resolved as variable. The behaviour is now aligned with handlebarsjs.
    • [Removed] Breaking option to disable source map is removed [#395]
    • [Removed] Breaking TemplateFileError and TemplateRenderError are removed and merged into TemplateError and RenderError [#395]
    Source code(tar.gz)
    Source code(zip)
  • v3.5.3(Feb 20, 2021)

Owner
Ning Sun
Programmer, at work and at home. Open source enthusiast. Linux user. Favourite languages: Clojure, Rust
Ning Sun
A blazingly fast static web server with routing, templating, and security in a single binary you can set up with zero code. :zap::crab:

binserve ⚡ ?? A blazingly fast static web server with routing, templating, and security in a single binary you can set up with zero code. ?? UPDATE: N

Mufeed VH 722 Dec 27, 2022
handle some lichess.org/tournament load with rust, while learning rust

lila-http Take some of the HTTP load away from lila. WIP! Arena tournaments Clients connected to a tournament page request new data about the tourname

Thibault Duplessis 22 Jan 2, 2023
Simple http server in Rust (Windows/Mac/Linux)

How it looks like? Screenshot Command Line Arguments Simple HTTP(s) Server 0.6.1 USAGE: simple-http-server [FLAGS] [OPTIONS] [--] [root] FLAGS:

LinFeng Qian 788 Dec 28, 2022
Rust / Hasura / GraphQL

Rust + Hasura This is an example of a Rust server that functions as a remote schema for Hasura. It demonstrates: user login + signup JWT authorization

Rónán 130 Dec 26, 2022
Actix Web is a powerful, pragmatic, and extremely fast web framework for Rust.

Actix Web Actix Web is a powerful, pragmatic, and extremely fast web framework for Rust Features Supports HTTP/1.x and HTTP/2 Streaming and pipelining

Actix 16.3k Jan 8, 2023
An HTTP library for Rust

hyper A fast and correct HTTP implementation for Rust. HTTP/1 and HTTP/2 Asynchronous design Leading in performance Tested and correct Extensive produ

null 11k Jan 7, 2023
JSON Web Token implementation in Rust.

Frank JWT Implementation of JSON Web Tokens in Rust. Algorithms and features supported HS256 HS384 HS512 RS256 RS384 RS512 ES256 ES384 ES512 Sign Veri

Alex Maslakov 246 Dec 27, 2022
An Extensible, Concurrent Web Framework for Rust

Iron Extensible, Concurrency Focused Web Development in Rust. Response Timer Example Note: This example works with the current iron code in this repos

null 6.1k Dec 27, 2022
GraphQL server library for Rust

GraphQL server library for Rust GraphQL is a data query language developed by Facebook intended to serve mobile and web application frontends. Juniper

GraphQL Rust 4.9k Jan 5, 2023
An expressjs inspired web framework for Rust

nickel.rs nickel.rs is a simple and lightweight foundation for web applications written in Rust. Its API is inspired by the popular express framework

null 3k Jan 3, 2023
[OUTDATED] A light HTTP framework for Rust

Rustful A light HTTP framework for Rust, with REST-like features. The main purpose of Rustful is to create a simple, modular and non-intrusive foundat

Erik Hedvall 873 Nov 12, 2022
A web framework for Rust.

Rocket Rocket is an async web framework for Rust with a focus on usability, security, extensibility, and speed. #[macro_use] extern crate rocket; #[g

Sergio Benitez 19.5k Jan 8, 2023
REST-like API micro-framework for Rust. Works with Iron.

Table of Contents What is Rustless? Usage warning Basic Usage Complex example Mounting Parameters validation and coercion Use JSON Schema Query string

Rustless 610 Jan 4, 2023
A lightweight web framework built on hyper, implemented in Rust language.

Sapper Sapper, a lightweight web framework, written in Rust. Sapper focuses on ergonomic usage and rapid development. It can work with stable Rust. Sa

Daogang Tang 622 Oct 27, 2022
Low level HTTP server library in Rust

tiny-http Documentation Tiny but strong HTTP server in Rust. Its main objectives are to be 100% compliant with the HTTP standard and to provide an eas

null 785 Dec 29, 2022
Web framework in Rust

Rouille, a Rust web micro-framework Rouille is a micro-web-framework library. It creates a listening socket and parses incoming HTTP requests from cli

Pierre Krieger 840 Jan 1, 2023
A fast, boilerplate free, web framework for Rust

Tower Web A web framework for Rust with a focus on removing boilerplate. API Documentation Tower Web is: Fast: Fully asynchronous, built on Tokio and

Carl Lerche 969 Dec 22, 2022
Sincere is a micro web framework for Rust(stable) based on hyper and multithreading

The project is no longer maintained! Sincere Sincere is a micro web framework for Rust(stable) based on hyper and multithreading. Style like koa. The

null 94 Oct 26, 2022
:zap: fast http framework for rust

zap ⚡ The mission of zap is, to deliver a basic, but fast rust web server library. Documentation About This code is based on tokio's minihttp project,

Daniel Oltmanns 51 Jun 7, 2022