Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
name: Lint & Tests
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: "3.3" # Not needed with a `.ruby-version` or `.tool-versions`
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- name: run lint
run: bundle exec rake rubocop
- name: install gems
run: bundle exec appraisal install
- name: run tests
run: bundle exec appraisal rake test
22 changes: 22 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
AllCops:
SuggestExtensions: false
NewCops: enable

Metrics/ModuleLength:
Enabled: false

Style/Documentation:
Enabled: false

Layout/MethodLength:
Enabled: false

Layout/LineLength:
Enabled: false

Metrics/AbcSize:
Enabled: false

Metrics/PerceivedComplexity:
Enabled: false
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.3.6
16 changes: 7 additions & 9 deletions Appraisals
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
appraise "sprockets-3" do
gem "sprockets", "3.0.0"
end
# frozen_string_literal: true

appraise "sprockets-2" do
gem "sprockets", "2.3.3"
appraise 'sprockets-4_2' do
gem 'sprockets', '4.2.1'
end

appraise "tilt-2" do
gem "tilt", "2.0.1"
appraise 'sprockets-4_1' do
gem 'sprockets', '4.1.1'
end

appraise "tilt-1" do
gem "tilt", "1.4.1"
appraise 'sprockets-4_0' do
gem 'sprockets', '4.0.3'
end
13 changes: 12 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
source "http://rubygems.org"
# frozen_string_literal: true

source 'http://rubygems.org'

gem 'appraisal'
gem 'haml', '~> 6.3'
gem 'slim', '~> 5.2'

gem 'minitest', '~> 5.25'
gem 'rake', '~> 13.2'
gem 'rubocop', require: false
gem 'rubocop-rake', require: false

# Specify your gem's dependencies in handlebars_assets.gemspec
gemspec
90 changes: 40 additions & 50 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ My pull request to allow `/` in partials was pulled into Handlebars. The hack th

# Installation

## Rails 4.0+
## Rails 6.0+

Load `handlebars_assets` in your `Gemfile`

Expand All @@ -32,23 +32,9 @@ gem 'handlebars_assets'

Then follow [Javascript Setup](#javascript-setup)

Side Note: _As of Rails 4.0, the `assets` group is not supported in the Gemfile ([source](http://edgeguides.rubyonrails.org/upgrading_ruby_on_rails.html#upgrading-from-rails-3-2-to-rails-4-0-gemfile))._

## Rails 3.1+

Load `handlebars_assets` in your `Gemfile` as part of the `assets` group

```ruby
group :assets do
gem 'handlebars_assets'
end
```

Then follow [Javascript Setup](#javascript-setup)

## Sprockets (Non-Rails)

`handlebars_assets` can work with earlier versions of Rails or other frameworks like Sinatra.
`handlebars_assets` can also work with other frameworks like Sinatra.

Load `handlebars_assets` in your `Gemfile`

Expand Down Expand Up @@ -86,9 +72,11 @@ If you need to compile your JavaScript templates in the browser as well, you sho
Generally you want to locate your template with your other assets, for example `app/assets/javascripts/templates`. In your JavaScript manifest file, use `require_tree` to pull in the templates

> app/assets/javascripts/application.js

```javascript
//= require_tree ./templates
```

This must be done before `//= require_tree .` otherwise all your templates will not have the intended prefix; and after your inclusion of handlebars/handlebars runtime.

## Rails Asset Precompiling
Expand Down Expand Up @@ -145,7 +133,7 @@ You can then invoke the resulting template in your application's JavaScript
NOTE: There will be no javascript object `HandlebarsTemplates` unless at least ONE template is included.

```javascript
HandlebarsTemplates['contacts/new'](context);
HandlebarsTemplates["contacts/new"](context);
```

## Partials
Expand All @@ -161,7 +149,7 @@ Invoke a {{> path/to/_partial }}
## The template namespace

By default, the global JavaScript object that holds the compiled templates is `HandlebarsTemplates`, but it can
be easily renamed. Another common template namespace is `JST`. Just change the `template_namespace` configuration option
be easily renamed. Another common template namespace is `JST`. Just change the `template_namespace` configuration option
when you initialize your application.

```ruby
Expand Down Expand Up @@ -201,8 +189,8 @@ For example, if you have a file `widget.hamlbars` that looks like this:
The Haml will be pre-processed so that the Handlebars template is basically this:

```html
<h1> {{title}} </h1>
<p> {{body}} </p>
<h1>{{title}}</h1>
<p>{{body}}</p>
```

The same applies to `.slimbars` and the Slim gem. Use `HandlebarsAssets::Config.slim_options` to pass custom options to the Slim rendering engine.
Expand Down Expand Up @@ -256,43 +244,45 @@ Thank you Charles Lowell (@cowboyd) for [therubyracer](https://github.com/cowboy

# Maintainer

This gem is maintained by Alex Riedler [Github](https://github.com/AlexRiedler).
This gem is currently maintained by Alex Riedler [Github](https://github.com/AlexRiedler).

# Author

Les Hill, follow me on [Github](https://github.com/leshill) and [Twitter](https://twitter.com/leshill).

# Contributors

* Matt Burke (@spraints) : execjs support
* (@kendagriff) : 1.8.7 compatibility
* Thorben Schröder (@walski) : 3.1 asset group for precompile
* Erwan Barrier (@erwanb) : Support for plain sprockets
* Brendan Loudermilk (@bloudermilk) : HandlebarsAssets.path
* Dan Evans (@danevans) : Rails 2 support
* Ben Woosley (@empact) : Update to handlebars.js 1.0.0.beta.6
* (@cw-moshe) : Remove 'templates/' from names
* Spike Brehm (@spikebrehm) : Config.template\_namespace option
* Ken Mayer (@kmayer) : Quick fix for template\_namespace option
* Brad Murray (@wyaeld) : Generic options support
* Blake Williams (@BlakeWilliams) : .handlebars extension
* Tristan Koch (@trkoch) : Strip leading whitespace from compiled templates
* Brian Cardarella (@bcardarella) : Ember support
* David Lee (@davidlee) : Slim support
* Phil Cohen (@phlipper) : README cleanup
* Akshay Rawat (@akshayrawat) : Update to handlebars.js 1.0.0-rc.3
* Turadg Aleahmad (@turadg) : Update to handlebars 1.0.0-rc.4
* Mark Rushakoff (@mark-rushakoff) : Synchronize Sprockets engine registers with Rails
* Alex Riedler (@AlexRiedler) : Pass scope and locals up the chain
* lee (@lee) : Update to handlebars 1.0.0
* Ken Collins (@metaskills) : Register with Sprockets
* Blake Hitchcock (@rbhitchcock) : Support ember and other handlebars use simultaneously
* ajk (@Darep) : Fix .hbs extension for multi-framework support
* (@mattmenefee) : README section for `hamlbars`
* Parker Selbert (@sorentwo) : README section for `multiple_frameworks`
* Francisco QV (@panchoqv) : README clarification
* Dylan Markow (@dmarkow) : README cleanup
* Peter Boling (@pboling) : AMD Loading
| Contributor | Work Done |
| --------------------------------- | ----------------------------------------------------- |
| Matt Burke (@spraints) | execjs support |
| (@kendagriff) | 1.8.7 compatibility |
| Thorben Schröder (@walski) | 3.1 asset group for precompile |
| Erwan Barrier (@erwanb) | Support for plain sprockets |
| Brendan Loudermilk (@bloudermilk) | HandlebarsAssets.path |
| Dan Evans (@danevans) | Rails 2 support |
| Ben Woosley (@empact) | Update to handlebars.js 1.0.0.beta.6 |
| (@cw-moshe) | Remove 'templates/' from names |
| Spike Brehm (@spikebrehm) | Config.template_namespace option |
| Ken Mayer (@kmayer) | Quick fix for template_namespace option |
| Brad Murray (@wyaeld) | Generic options support |
| Blake Williams (@BlakeWilliams) | .handlebars extension |
| Tristan Koch (@trkoch) | Strip leading whitespace from compiled templates |
| Brian Cardarella (@bcardarella) | Ember support |
| David Lee (@davidlee) | Slim support |
| Phil Cohen (@phlipper) | README cleanup |
| Akshay Rawat (@akshayrawat) | Update to handlebars.js 1.0.0-rc.3 |
| Turadg Aleahmad (@turadg) | Update to handlebars 1.0.0-rc.4 |
| Mark Rushakoff (@mark-rushakoff) | Synchronize Sprockets engine registers with Rails |
| Alex Riedler (@AlexRiedler) | Pass scope and locals up the chain |
| lee (@lee) | Update to handlebars 1.0.0 |
| Ken Collins (@metaskills) | Register with Sprockets |
| Blake Hitchcock (@rbhitchcock) | Support ember and other handlebars use simultaneously |
| ajk (@Darep) | Fix .hbs extension for multi-framework support |
| (@mattmenefee) | README section for `hamlbars` |
| Parker Selbert (@sorentwo) | README section for `multiple_frameworks` |
| Francisco QV (@panchoqv) | README clarification |
| Dylan Markow (@dmarkow) | README cleanup |
| Peter Boling (@pboling) | AMD Loading |

# Contributing

Expand Down
17 changes: 12 additions & 5 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
require "rubygems"
require "bundler/setup"
require "bundler/gem_tasks"
require "rake/testtask"
# frozen_string_literal: true

require 'rubygems'
require 'bundler/setup'
require 'bundler/gem_tasks'
require 'rake/testtask'
require 'rubocop/rake_task'

Rake::TestTask.new do |t|
t.libs << 'test'
t.test_files = FileList['test/**/*_test.rb']
end

task :default => :test
RuboCop::RakeTask.new do |task|
task.requires << 'rubocop-rake'
end

task default: :test
8 changes: 0 additions & 8 deletions gemfiles/rails_4_1.gemfile

This file was deleted.

8 changes: 0 additions & 8 deletions gemfiles/rails_4_2.gemfile

This file was deleted.

8 changes: 0 additions & 8 deletions gemfiles/rails_5.gemfile

This file was deleted.

7 changes: 0 additions & 7 deletions gemfiles/sprockets_2.gemfile

This file was deleted.

7 changes: 0 additions & 7 deletions gemfiles/sprockets_3.gemfile

This file was deleted.

16 changes: 16 additions & 0 deletions gemfiles/sprockets_4_0.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# frozen_string_literal: true

# This file was generated by Appraisal

source 'http://rubygems.org'

gem 'appraisal'
gem 'haml', '~> 6.3'
gem 'minitest', '~> 5.25'
gem 'rake', '~> 13.2'
gem 'rubocop', require: false
gem 'rubocop-rake', require: false
gem 'slim', '~> 5.2'
gem 'sprockets', '4.0.3'

gemspec path: '../'
16 changes: 16 additions & 0 deletions gemfiles/sprockets_4_1.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# frozen_string_literal: true

# This file was generated by Appraisal

source 'http://rubygems.org'

gem 'appraisal'
gem 'haml', '~> 6.3'
gem 'minitest', '~> 5.25'
gem 'rake', '~> 13.2'
gem 'rubocop', require: false
gem 'rubocop-rake', require: false
gem 'slim', '~> 5.2'
gem 'sprockets', '4.1.1'

gemspec path: '../'
16 changes: 16 additions & 0 deletions gemfiles/sprockets_4_2.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# frozen_string_literal: true

# This file was generated by Appraisal

source 'http://rubygems.org'

gem 'appraisal'
gem 'haml', '~> 6.3'
gem 'minitest', '~> 5.25'
gem 'rake', '~> 13.2'
gem 'rubocop', require: false
gem 'rubocop-rake', require: false
gem 'slim', '~> 5.2'
gem 'sprockets', '4.2.1'

gemspec path: '../'
7 changes: 0 additions & 7 deletions gemfiles/tilt_1.gemfile

This file was deleted.

7 changes: 0 additions & 7 deletions gemfiles/tilt_2.gemfile

This file was deleted.

Loading
Loading