Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch from Mustache to Handlebars #559

Merged
merged 1 commit into from
May 26, 2016
Merged

Switch from Mustache to Handlebars #559

merged 1 commit into from
May 26, 2016

Conversation

adamhjk
Copy link
Contributor

@adamhjk adamhjk commented May 25, 2016

gif-keyboard-16909652391474939466

This is a breaking change - any plan that uses anything more complex than variable substitution will break. See Handlebars for new template options, and handlebars-rust for our specific implementation. One tweak is that we do no escaping whatsoever of variables we replace.

This commit moves the templating system from Mustache to Handlebars. It
brings us a couple of things:

  1. Handlebars is a more flexible templating system; the Rust
    implementation we are using will allow us to add custom handlers if we
    want, making it easy to customize the templating system.

  2. Handlebars uses the full Javascript true/false behavior on the
    {{if}} conditional. That means you can have values that use the
    empty string evaluate correctly, making it much easier to write
    templates.

  3. Handlebars supports trimming whitespace with ~

  4. Handlebars sets us up to support registering all the templates in a
    plan, and letting you use some as partials.

  5. The syntax is slightly more verbose than Mustache. For example:

{{#if cfg.your_value}}{{cfg.your_value}}{{/if}}

Versus

{{#cfg.your_value}}{{cfg.your_value}}{{/cfg.your_value}}

(Also, the Mustache version doesn't work unless the value of
cfg.your_value is an array. This sucks. See reason 2)

Additionally, I replaced our use of the openssl hash function with the
same Blake2B hash we use elsewhere when deciding if we need to re-render
a configuration template.

Signed-off-by: Adam Jacob [email protected]

This commit moves the templating system from Mustache to Handlebars. It
brings us a couple of things:

1) Handlebars is a more flexible templating system; the Rust
implementation we are using will allow us to add custom handlers if we
want, making it easy to customize the templating system.

2) Handlebars uses the full Javascript true/false behavior on the
``{{if}}`` conditional. That means you can have values that use the
empty string evaluate correctly, making it much easier to write
templates.

3) Handlebars supports trimming whitespace with ``~``

4) Handlebars sets us up to support registering all the templates in a
plan, and letting you use some as partials.

5) The syntax is slightly more verbose than Mustache. For example:

```
{{#if cfg.your_value}}{{cfg.your_value}}{{/if}}
```

Versus

```
{{#cfg.your_value}}{{cfg.your_value}}{{/cfg.your_value}}
```

(Also, the Mustache version doesn't work unless the value of
``cfg.your_value`` is an array. This sucks. See reason 2)

Additionally, I replaced our use of the openssl hash function with the
same Blake2B hash we use elsewhere when deciding if we need to re-render
a configuration template.

Signed-off-by: Adam Jacob <[email protected]>
@thesentinels
Copy link
Contributor

By analyzing the blame information on this pull request, we identified @reset, @metadave, @fnichol, @juliandunn and @adamhjk to be potential reviewers

@reset
Copy link
Collaborator

reset commented May 25, 2016

@adamhjk so much nicer than mustache!

gif-keyboard-12715762004124279283

@thesentinels r+

@thesentinels
Copy link
Contributor

📌 Commit 8e3d079 has been approved by reset

@thesentinels
Copy link
Contributor

⌛ Testing commit 8e3d079 with merge 99799c1...

thesentinels pushed a commit that referenced this pull request May 25, 2016
This commit moves the templating system from Mustache to Handlebars. It
brings us a couple of things:

1) Handlebars is a more flexible templating system; the Rust
implementation we are using will allow us to add custom handlers if we
want, making it easy to customize the templating system.

2) Handlebars uses the full Javascript true/false behavior on the
``{{if}}`` conditional. That means you can have values that use the
empty string evaluate correctly, making it much easier to write
templates.

3) Handlebars supports trimming whitespace with ``~``

4) Handlebars sets us up to support registering all the templates in a
plan, and letting you use some as partials.

5) The syntax is slightly more verbose than Mustache. For example:

```
{{#if cfg.your_value}}{{cfg.your_value}}{{/if}}
```

Versus

```
{{#cfg.your_value}}{{cfg.your_value}}{{/cfg.your_value}}
```

(Also, the Mustache version doesn't work unless the value of
``cfg.your_value`` is an array. This sucks. See reason 2)

Additionally, I replaced our use of the openssl hash function with the
same Blake2B hash we use elsewhere when deciding if we need to re-render
a configuration template.

Signed-off-by: Adam Jacob <[email protected]>

Pull request: #559
Approved by: reset
@thesentinels
Copy link
Contributor

☀️ Test successful - travis

@thesentinels thesentinels merged commit 8e3d079 into master May 26, 2016
@fnichol fnichol deleted the handlebars branch May 27, 2016 04:02
jtimberman pushed a commit that referenced this pull request Jun 12, 2016
This commit moves the templating system from Mustache to Handlebars. It
brings us a couple of things:

1) Handlebars is a more flexible templating system; the Rust
implementation we are using will allow us to add custom handlers if we
want, making it easy to customize the templating system.

2) Handlebars uses the full Javascript true/false behavior on the
``{{if}}`` conditional. That means you can have values that use the
empty string evaluate correctly, making it much easier to write
templates.

3) Handlebars supports trimming whitespace with ``~``

4) Handlebars sets us up to support registering all the templates in a
plan, and letting you use some as partials.

5) The syntax is slightly more verbose than Mustache. For example:

```
{{#if cfg.your_value}}{{cfg.your_value}}{{/if}}
```

Versus

```
{{#cfg.your_value}}{{cfg.your_value}}{{/cfg.your_value}}
```

(Also, the Mustache version doesn't work unless the value of
``cfg.your_value`` is an array. This sucks. See reason 2)

Additionally, I replaced our use of the openssl hash function with the
same Blake2B hash we use elsewhere when deciding if we need to re-render
a configuration template.

Signed-off-by: Adam Jacob <[email protected]>

Pull request: #559
Approved by: reset
raskchanky pushed a commit that referenced this pull request Apr 16, 2019
This commit moves the templating system from Mustache to Handlebars. It
brings us a couple of things:

1) Handlebars is a more flexible templating system; the Rust
implementation we are using will allow us to add custom handlers if we
want, making it easy to customize the templating system.

2) Handlebars uses the full Javascript true/false behavior on the
``{{if}}`` conditional. That means you can have values that use the
empty string evaluate correctly, making it much easier to write
templates.

3) Handlebars supports trimming whitespace with ``~``

4) Handlebars sets us up to support registering all the templates in a
plan, and letting you use some as partials.

5) The syntax is slightly more verbose than Mustache. For example:

```
{{#if cfg.your_value}}{{cfg.your_value}}{{/if}}
```

Versus

```
{{#cfg.your_value}}{{cfg.your_value}}{{/cfg.your_value}}
```

(Also, the Mustache version doesn't work unless the value of
``cfg.your_value`` is an array. This sucks. See reason 2)

Additionally, I replaced our use of the openssl hash function with the
same Blake2B hash we use elsewhere when deciding if we need to re-render
a configuration template.

Signed-off-by: Adam Jacob <[email protected]>

Pull request: #559
Approved by: reset
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants