trainingwheels 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md ADDED
@@ -0,0 +1,31 @@
1
+ Training Wheels
2
+ =======================
3
+
4
+ Put Training Wheels on your Handlebar Templates so they can ride with Ember
5
+ -----------------------
6
+
7
+ ## What the?
8
+ This is a simple Sprockets engine that wraps your handlebar templates up and puts them into Ember's TEMPLATES global var, so you can access them like this:
9
+
10
+ ```javascript
11
+ //= require_tree ./templates
12
+ App.NewAuthView = Ember.View.extend({
13
+ layoutName: "auth/new",
14
+ templateName: "auth/login_form"
15
+ });
16
+ ```
17
+
18
+ ## How to use/install:
19
+ Simply install the gem (trainingwheels) or include it in your gemfile.
20
+
21
+ Now you just need to use the "require" or "require_tree" Sprockets directive to load your templates:
22
+
23
+ ```javascript
24
+ //= require_tree ./templates
25
+ ```
26
+
27
+ And your templates will automatically be available in your Ember views!
28
+
29
+ ## Issues? Problems?
30
+
31
+ Feel free to submit issues or pull requests!
@@ -0,0 +1,14 @@
1
+ require "training_wheels/version"
2
+
3
+ module TrainingWheels
4
+ autoload(:TiltHandlebars, 'training_wheels/tilt_handlebars')
5
+ autoload(:Config, 'training_wheels/config')
6
+
7
+ if defined?(Rails) && defined?(::Rails::Engine)
8
+ require 'training_wheels/engine'
9
+ else
10
+ require 'sprockets'
11
+ Sprockets.register_engine '.hbs', TiltHandlebars
12
+ Sprockets.register_engine '.handlebars', TiltHandlebars
13
+ end
14
+ end
@@ -0,0 +1,10 @@
1
+ module TrainingWheels
2
+ module Config
3
+ extend self
4
+ attr_writer :path_prefix
5
+
6
+ def path_prefix
7
+ @path_prefix || 'templates'
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,9 @@
1
+ module TrainingWheels
2
+ class Engine < ::Rails::Engine
3
+ initializer "sprockets.handlebars", :after => "sprockets.environment", :group => :all do |app|
4
+ next unless app.assets
5
+ app.assets.register_engine('.hbs', TiltHandlebars)
6
+ app.assets.register_engine('.handlebars', TiltHandlebars)
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,47 @@
1
+ require 'tilt'
2
+
3
+ module TrainingWheels
4
+ class TiltHandlebars < Tilt::Template
5
+ def self.default_mime_type
6
+ 'application/javascript'
7
+ end
8
+
9
+ def evaluate(scope, locals, &block)
10
+ template_path = TemplatePath.new(scope)
11
+
12
+ "Ember.TEMPLATES[#{template_path.name}] = Ember.Handlebars.compile(#{data.inspect})"
13
+ end
14
+
15
+ protected
16
+
17
+ def prepare; end
18
+
19
+ # based on / copied from leshill/handlebars_assets
20
+ class TemplatePath
21
+ def initialize(scope)
22
+ self.template_path = scope.logical_path
23
+ end
24
+
25
+ def name
26
+ template_name
27
+ end
28
+
29
+ private
30
+
31
+ attr_accessor :template_path
32
+
33
+ def forced_underscore_name
34
+ '_' + relative_path
35
+ end
36
+
37
+ def relative_path
38
+ template_path.gsub(/^#{TrainingWheels::Config.path_prefix}\/(.*)$/i, "\\1")
39
+ end
40
+
41
+ def template_name
42
+ relative_path.dump
43
+ end
44
+ end
45
+ end
46
+
47
+ end
@@ -0,0 +1,3 @@
1
+ module TrainingWheels
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "training_wheels/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "trainingwheels"
7
+ s.version = TrainingWheels::VERSION
8
+ s.authors = ["Conrad VanLandingham"]
9
+ s.email = ["conrad@landdolph.in"]
10
+ s.homepage = ""
11
+ s.summary = "A simple Sprockets engine that puts training wheels on your Handlebar templates (wraps them up and adds them to Ember's global TEMPLATE variable)"
12
+ s.description = "A simple Sprockets engine that puts training wheels on your Handlebar templates (wraps them up and adds them to Ember's global TEMPLATE variable)"
13
+
14
+ s.files = `git ls-files`.split("\n")
15
+ s.require_paths = ["lib"]
16
+
17
+ # s.add_runtime_dependency "execjs", ">= 1.2.9"
18
+ s.add_runtime_dependency "tilt"
19
+ s.add_runtime_dependency "sprockets", ">= 2.0.3"
20
+ s.add_development_dependency "rake"
21
+ end
metadata ADDED
@@ -0,0 +1,87 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: trainingwheels
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Conrad VanLandingham
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-09-04 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: tilt
16
+ requirement: &21911868 !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: *21911868
25
+ - !ruby/object:Gem::Dependency
26
+ name: sprockets
27
+ requirement: &21179772 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: 2.0.3
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *21179772
36
+ - !ruby/object:Gem::Dependency
37
+ name: rake
38
+ requirement: &21177900 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *21177900
47
+ description: A simple Sprockets engine that puts training wheels on your Handlebar
48
+ templates (wraps them up and adds them to Ember's global TEMPLATE variable)
49
+ email:
50
+ - conrad@landdolph.in
51
+ executables: []
52
+ extensions: []
53
+ extra_rdoc_files: []
54
+ files:
55
+ - README.md
56
+ - lib/training_wheels.rb
57
+ - lib/training_wheels/config.rb
58
+ - lib/training_wheels/engine.rb
59
+ - lib/training_wheels/tilt_handlebars.rb
60
+ - lib/training_wheels/version.rb
61
+ - trainingwheels.gemspec
62
+ homepage: ''
63
+ licenses: []
64
+ post_install_message:
65
+ rdoc_options: []
66
+ require_paths:
67
+ - lib
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ none: false
70
+ requirements:
71
+ - - ! '>='
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ required_rubygems_version: !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ! '>='
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ requirements: []
81
+ rubyforge_project:
82
+ rubygems_version: 1.8.11
83
+ signing_key:
84
+ specification_version: 3
85
+ summary: A simple Sprockets engine that puts training wheels on your Handlebar templates
86
+ (wraps them up and adds them to Ember's global TEMPLATE variable)
87
+ test_files: []