emblem-sprockets 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +18 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +1 -0
- data/emblem-sprockets.gemspec +20 -0
- data/lib/emblem-sprockets.rb +1 -0
- data/lib/emblem/sprockets.rb +11 -0
- data/lib/emblem/sprockets/integration.rb +11 -0
- data/lib/emblem/sprockets/template.rb +54 -0
- data/lib/emblem/sprockets/version.rb +5 -0
- metadata +74 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 A. Speller
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Emblem::Sprockets
|
2
|
+
|
3
|
+
Integrate [Emblem.js](https://github.com/machty/emblem.js) with sprockets
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add `gem 'emblem-sprockets'` to your application's Gemfile :
|
8
|
+
|
9
|
+
gem 'emblem-sprockets'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Tell emblem-sprockets about your sprockets environment:
|
16
|
+
|
17
|
+
Emblem::Sprockets.integrate sprockets_environment
|
18
|
+
|
19
|
+
Now any templates ending in `.emblem` will be compiled as
|
20
|
+
Ember-Handlebars templates. If you need to compile your Emblem templates
|
21
|
+
with vanilla Handlebars, use the `.raw.emblem` extension.
|
22
|
+
|
23
|
+
## Upgrading to the latest Emblem
|
24
|
+
|
25
|
+
This gem is only responsible for integrating Emblem.js with Sprockets. Any
|
26
|
+
updates to the Emblem language itself can be pulled in via
|
27
|
+
|
28
|
+
$ bundle update emblem-source
|
29
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'emblem/sprockets/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "emblem-sprockets"
|
8
|
+
gem.version = Emblem::Sprockets::VERSION
|
9
|
+
gem.authors = ["Alex Speller", "Alex Matchneer", "Micah Geisel"]
|
10
|
+
gem.email = ["micah@botandrose.com"]
|
11
|
+
gem.description = %q{Use emblem.js with sprockets - see https://github.com/machty/emblem.js}
|
12
|
+
gem.summary = %q{Use emblem.js with sprockets}
|
13
|
+
gem.homepage = "http://github.com/botandrose/emblem-sprockets"
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
gem.add_dependency "barber-emblem"
|
20
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require "emblem/sprockets"
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'sprockets'
|
2
|
+
require 'sprockets/engines'
|
3
|
+
require 'barber-emblem'
|
4
|
+
|
5
|
+
module Emblem
|
6
|
+
module Sprockets
|
7
|
+
class Template < Tilt::Template
|
8
|
+
def self.default_mime_type
|
9
|
+
'application/javascript'
|
10
|
+
end
|
11
|
+
|
12
|
+
def prepare; end
|
13
|
+
|
14
|
+
def evaluate(scope, locals, &block)
|
15
|
+
target = template_target(scope)
|
16
|
+
|
17
|
+
template = data
|
18
|
+
|
19
|
+
if raw?(scope)
|
20
|
+
template = precompile_emblem(template)
|
21
|
+
else
|
22
|
+
template = precompile_ember_emblem(template)
|
23
|
+
end
|
24
|
+
|
25
|
+
"#{target} = #{template}\n"
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def raw?(scope)
|
32
|
+
scope.pathname.to_s =~ /\.raw\.(emblem)/
|
33
|
+
end
|
34
|
+
|
35
|
+
def template_target(scope)
|
36
|
+
"Ember.TEMPLATES[#{template_path(scope.logical_path).inspect}]"
|
37
|
+
end
|
38
|
+
|
39
|
+
def precompile_emblem(string)
|
40
|
+
Barber::Emblem::FilePrecompiler.call(string)
|
41
|
+
end
|
42
|
+
|
43
|
+
def precompile_ember_emblem(string)
|
44
|
+
Barber::Emblem::EmberFilePrecompiler.call(string)
|
45
|
+
end
|
46
|
+
|
47
|
+
def template_path(path)
|
48
|
+
path = path.split('/')
|
49
|
+
path.shift # drop initial "templates/" prefix
|
50
|
+
path.join('/')
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
metadata
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: emblem-sprockets
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.1.0
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Alex Speller
|
9
|
+
- Alex Matchneer
|
10
|
+
- Micah Geisel
|
11
|
+
autorequire:
|
12
|
+
bindir: bin
|
13
|
+
cert_chain: []
|
14
|
+
date: 2013-04-18 00:00:00.000000000 Z
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
prerelease: false
|
18
|
+
type: :runtime
|
19
|
+
name: barber-emblem
|
20
|
+
version_requirements: !ruby/object:Gem::Requirement
|
21
|
+
none: false
|
22
|
+
requirements:
|
23
|
+
- - ! '>='
|
24
|
+
- !ruby/object:Gem::Version
|
25
|
+
version: '0'
|
26
|
+
requirement: !ruby/object:Gem::Requirement
|
27
|
+
none: false
|
28
|
+
requirements:
|
29
|
+
- - ! '>='
|
30
|
+
- !ruby/object:Gem::Version
|
31
|
+
version: '0'
|
32
|
+
description: Use emblem.js with sprockets - see https://github.com/machty/emblem.js
|
33
|
+
email:
|
34
|
+
- micah@botandrose.com
|
35
|
+
executables: []
|
36
|
+
extensions: []
|
37
|
+
extra_rdoc_files: []
|
38
|
+
files:
|
39
|
+
- .gitignore
|
40
|
+
- Gemfile
|
41
|
+
- LICENSE.txt
|
42
|
+
- README.md
|
43
|
+
- Rakefile
|
44
|
+
- emblem-sprockets.gemspec
|
45
|
+
- lib/emblem-sprockets.rb
|
46
|
+
- lib/emblem/sprockets.rb
|
47
|
+
- lib/emblem/sprockets/integration.rb
|
48
|
+
- lib/emblem/sprockets/template.rb
|
49
|
+
- lib/emblem/sprockets/version.rb
|
50
|
+
homepage: http://github.com/botandrose/emblem-sprockets
|
51
|
+
licenses: []
|
52
|
+
post_install_message:
|
53
|
+
rdoc_options: []
|
54
|
+
require_paths:
|
55
|
+
- lib
|
56
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
63
|
+
none: false
|
64
|
+
requirements:
|
65
|
+
- - ! '>='
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
requirements: []
|
69
|
+
rubyforge_project:
|
70
|
+
rubygems_version: 1.8.25
|
71
|
+
signing_key:
|
72
|
+
specification_version: 3
|
73
|
+
summary: Use emblem.js with sprockets
|
74
|
+
test_files: []
|