sprockets-handlebars_template 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md ADDED
@@ -0,0 +1,3 @@
1
+ ## 0.0.1 (xx)
2
+
3
+ First version.
data/README.md ADDED
@@ -0,0 +1,70 @@
1
+ # sprockets-handlebars_template, a handlebars template for sprockets. [![Build Status](https://secure.travis-ci.org/GutenYe/sprockets-handlebars_template.png)](http://travis-ci.org/GutenYe/sprockets-handlebars_template)
2
+
3
+ | | |
4
+ |----------------|------------------------------------------------------ |
5
+ | Homepage: | https://github.com/GutenYe/sprockets-handlebars_template |
6
+ | Author: | Guten |
7
+ | License: | MIT-LICENSE |
8
+ | Documentation: | http://rubydoc.info/gems/sprockets-handlebars_template/frames |
9
+ | Issue Tracker: | https://github.com/GutenYe/sprockets-handlebars_template/issues |
10
+ | Ruby Versions: | 1.9.3, Rubinius, JRuby |
11
+
12
+ A simple handlebars template for sprockets, you can use it with Sprockets, Middleman, Rails, Sinatra, ... It supports Handlebars and Ember.Handlebars.
13
+
14
+ Getting started
15
+ ---------------
16
+
17
+ For handlebars
18
+
19
+ require "sprockets/handlebars_template"
20
+
21
+ For ember
22
+
23
+ require "sprockets/ember_handlebars_template"
24
+
25
+ Configuration
26
+ -------------
27
+
28
+ Sprockets::HandlebarsTemplate.options = {
29
+ :target => "Handlebars.TEMPLATES",
30
+ :wrapper_proc => proc { |source| "Handlebars.compile(#{source});" },
31
+ :key_name_proc => proc { |name| name.sub(%r~^templates/~, "") },
32
+ :precompile => true,
33
+ :precompile_proc => proc { |source| Barber::FilePrecompiler.call(source) }
34
+ }
35
+
36
+ Install
37
+ -------
38
+
39
+ $ [sudo] gem install sprockets-handlebars_template
40
+
41
+ Development [![Dependency Status](https://gemnasium.com/GutenYe/sprockets-handlebars_template.png?branch=master)](https://gemnasium.com/GutenYe/sprockets-handlebars_template) [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/GutenYe/sprockets-handlebars_template)
42
+ ===========
43
+
44
+ Contributing
45
+ -------------
46
+
47
+ * Submit any bugs/features/ideas to github issue tracker.
48
+
49
+ Please see [Contibution Documentation](https://github.com/GutenYe/sprockets-handlebars_template/blob/master/CONTRIBUTING.md).
50
+
51
+ A list of [Contributors](https://github.com/GutenYe/sprockets-handlebars_template/contributors).
52
+
53
+ Resources
54
+ ---------
55
+
56
+ * [sprockets](https://github.com/sstephenson/sprockets): Rack-based asset packaging system
57
+ * [handlebars.js](https://github.com/wycats/handlebars.js): Logicless templating languages that keep the view and the code separated like we all know they should be
58
+
59
+ Copyright
60
+ ---------
61
+
62
+ (the MIT License)
63
+
64
+ Copyright (c) 2012 Guten
65
+
66
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
67
+
68
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
69
+
70
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1 @@
1
+ require "sprockets/handlebars_template"
@@ -0,0 +1,7 @@
1
+ require "sprockets/handlebars_template"
2
+
3
+ Sprockets::HandlebarsTemplate.options = {
4
+ :target =>"Ember.TEMPLATES",
5
+ :wrapper_proc => proc { |source| "Ember.Handlebars.compile(#{source.to_json});" },
6
+ :precompile_proc => proc { |source| Barber::Ember::FilePrecompiler.call(source) }
7
+ }
@@ -0,0 +1,48 @@
1
+ require "sprockets"
2
+ require "sprockets/handlebars_template/loader"
3
+
4
+ module Sprockets
5
+ class HandlebarsTemplate < Tilt::Template
6
+ self.default_mime_type = "application/javascript"
7
+
8
+ @@options = {
9
+ :target =>"Handlebars.TEMPLATES",
10
+ :wrapper_proc => proc { |source| %!Handlebars.compile(#{source.to_json});! },
11
+ :key_name_proc => proc { |name| name.sub(%r~^templates/~, "") },
12
+ :precompile => true,
13
+ :precompile_proc => proc { |source| Barber::FilePrecompiler.call(source) }
14
+ }
15
+
16
+ def self.options=(options)
17
+ @@options.merge!(options)
18
+ end
19
+
20
+ def self.options
21
+ @@options
22
+ end
23
+
24
+ def self.engine_initialized?
25
+ String.respond_to?(:to_json) && respond_to?(:Barber)
26
+ end
27
+
28
+ def initialize_engine
29
+ require_template_library "json"
30
+ require_template_library "barber"
31
+ end
32
+
33
+ def prepare
34
+ end
35
+
36
+ def evaluate(scope, locals, &block)
37
+ @options = self.class.options.merge(options)
38
+ name = options[:key_name_proc].call(scope.logical_path)
39
+ wrap_proc = options[ options[:precompile] ? :precompile_proc : :wrapper_proc]
40
+ source = wrap_proc.call(data)
41
+
42
+ "#{options[:target]}['#{name}']=#{source}"
43
+ end
44
+ end
45
+
46
+ register_engine ".handlebars", HandlebarsTemplate
47
+ register_engine ".hbs", HandlebarsTemplate
48
+ end
@@ -0,0 +1,3 @@
1
+ if defined?(Rails)
2
+ require "sprockets/handlebars_template/rails"
3
+ end
@@ -0,0 +1,6 @@
1
+ module Sprockets
2
+ class HandlebarsTemplate
3
+ class RailsEngine < Rails::Engine
4
+ end
5
+ end
6
+ end
metadata ADDED
@@ -0,0 +1,85 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sprockets-handlebars_template
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Guten
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-12-23 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: sprockets
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: barber
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ description: ! 'a handlebars template for sprockets.
47
+
48
+ '
49
+ email: ywzhaifei@gmail.com
50
+ executables: []
51
+ extensions: []
52
+ extra_rdoc_files: []
53
+ files:
54
+ - CHANGELOG.md
55
+ - README.md
56
+ - lib/sprockets/ember_handlebars_template.rb
57
+ - lib/sprockets/handlebars_template/rails.rb
58
+ - lib/sprockets/handlebars_template/loader.rb
59
+ - lib/sprockets/handlebars_template.rb
60
+ - lib/sprockets-handlebars_template.rb
61
+ homepage: http://github.com/GutenYe/sprockets-handlebars_template
62
+ licenses: []
63
+ post_install_message:
64
+ rdoc_options: []
65
+ require_paths:
66
+ - lib
67
+ required_ruby_version: !ruby/object:Gem::Requirement
68
+ none: false
69
+ requirements:
70
+ - - ! '>='
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ! '>='
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ requirements: []
80
+ rubyforge_project:
81
+ rubygems_version: 1.8.24
82
+ signing_key:
83
+ specification_version: 3
84
+ summary: a handlebars template for sprockets.
85
+ test_files: []