<commit_before># handlebar_wax

## What is it?

HandlebarWax is a gem to let you easily share mustache templates between your server-side and client-side code. 

On the server, HandlebarWax uses code borrowed from handlebars-rails to support *.*.hbs as a template type (think foo.html.erb, foo.html.haml, foo.html.hbs). These work pretty much exactly like you would expect they should.

For the client side, HandlebarWax writes all your templates into public/javascripts/handlebars_templates.js, for you to use in your JavaScript code.

## How do I use it?

1. Add it to your gemfile.

    gem "mustache_wax"

2. Add it to your layout (it's important that ":handlebar_wax" be a symbol, not a string)

    = javascript_include_tag 'stuff.js', 'things.js', :handlebar_wax

This mostly includes javascripts/handlebars.js and javascripts/handlebars_templates.js.

3. Create view files.

    (app/views/users/_user.html.hbs)

    \<h1>{{greeting}},  {{user/name}}!\</h1>

4. Render views from rails.

    - @user = User.first
    = render :partial => 'users/user', :locals => {:greeting => "Hello"}

Note that in MustacheWax, hbs templates understand both assigns and locals.
    
5. Render views from JavaScript

    var user = Handlebars.compile(HandlebarsTemplates['users/_user']);
    user({user: {name: "Why"}}, greeting: "Frabjous Day")

## Who made this possible?

* <NAME> (ssoroka) for pub-based discussion about this, and initial mustache_wax code
* Jamesarosen for handlebars-rails, which this project includes in its entirety, with very few modifications as of yet.
* <NAME> (wycats) for the wonderful Handlebars.js.
<commit_msg>I should really learn markdown syntax for real.<commit_after># handlebar_wax

## What is it?

HandlebarWax is a gem to let you easily share mustache templates between your server-side and client-side code. 

On the server, HandlebarWax uses code borrowed from handlebars-rails to support *.*.hbs as a template type (think foo.html.erb, foo.html.haml, foo.html.hbs). These work pretty much exactly like you would expect they should.

For the client side, HandlebarWax writes all your templates into public/javascripts/handlebars_templates.js, for you to use in your JavaScript code.

## How do I use it?

1. Add it to your gemfile.

`gem "mustache_wax"`

2. Add it to your layout (it's important that ":handlebar_wax" be a symbol, not a string)

`= javascript_include_tag 'stuff.js', 'things.js', :handlebar_wax`

This mostly includes javascripts/handlebars.js and javascripts/handlebars_templates.js.

3. Create view files.

`(app/views/users/_user.html.hbs)`

`\<h1>{{greeting}},  {{user/name}}!\</h1>`

4. Render views from rails.

`- @user = User.first`
`= render :partial => 'users/user', :locals => {:greeting => "Hello"}`

Note that in MustacheWax, hbs templates understand both assigns and locals.
    
5. Render views from JavaScript

`var user = Handlebars.compile(HandlebarsTemplates['users/_user']);`
`user({user: {name: "Why"}}, greeting: "Frabjous Day")`

## Who made this possible?

* <NAME> (ssoroka) for pub-based discussion about this, and initial mustache_wax code
* Jamesarosen for handlebars-rails, which this project includes in its entirety, with very few modifications as of yet.
* <NAME> (wycats) for the wonderful Handlebars.js.

{'fraction_non_alphanumeric': 0.10486322188449848, 'fraction_numerical': 0.00425531914893617, 'mean_word_length': 4.351219512195122, 'pattern_counts': {'":': 2, '<': 11, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3241477', 'n_tokens_mistral': 1050, 'n_tokens_neox': 1006, 'n_words': 395}