sprockets-jst-str 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,14 @@
1
+
2
+ require 'sprockets-jst-str/version'
3
+
4
+ module SprocketsJstStr
5
+
6
+ autoload(:StrTemplate, 'sprockets-jst-str/str_template')
7
+
8
+ if defined?(Rails)
9
+ require 'sprockets-jst-str/engine'
10
+ else
11
+ require 'sprockets'
12
+ Sprockets.register_engine ".str", StrTemplate
13
+ end
14
+ end
@@ -0,0 +1,9 @@
1
+
2
+ module SprocketsJstStr
3
+ class Engine < ::Rails::Engine
4
+ initializer "sprockets.jst_str", :after => "sprockets.environment", :group => :all do |app|
5
+ next unless app.assets
6
+ app.assets.register_engine(".str", StrTemplate)
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,31 @@
1
+ require 'tilt'
2
+
3
+ module SprocketsJstStr
4
+
5
+ # Tilt engine class for the String compiler.
6
+ class StrTemplate < Tilt::Template
7
+
8
+ def self.engine_initialized?
9
+ true
10
+ end
11
+
12
+ def initialize_engine
13
+ end
14
+
15
+ def prepare
16
+ end
17
+
18
+ # Compile template data into a simple JS string.
19
+ def evaluate(scope, locals, &block)
20
+
21
+ str = data
22
+ str.gsub!(/\\/) { '\\\\' }
23
+ str.gsub!(/'/) { "\\'" }
24
+ str.gsub!(/\r/, '\\r')
25
+ str.gsub!(/\n/, '\\n')
26
+ str.gsub!(/\t/, '\\t')
27
+
28
+ "'#{str}';"
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,4 @@
1
+
2
+ module SprocketsJstStr
3
+ VERSION = "1.0.0"
4
+ end
metadata ADDED
@@ -0,0 +1,82 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sprockets-jst-str
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 1.0.0
6
+ platform: ruby
7
+ authors:
8
+ - Chetan Sarva
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-04-06 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: tilt
16
+ version_requirements: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 1.3.3
22
+ requirement: !ruby/object:Gem::Requirement
23
+ none: false
24
+ requirements:
25
+ - - ! '>='
26
+ - !ruby/object:Gem::Version
27
+ version: 1.3.3
28
+ type: :runtime
29
+ prerelease: false
30
+ - !ruby/object:Gem::Dependency
31
+ name: sprockets
32
+ version_requirements: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: 2.0.3
38
+ requirement: !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: 2.0.3
44
+ type: :runtime
45
+ prerelease: false
46
+ description: Slurps template into a JavaScript string for use with Sprockets JST functionality
47
+ email:
48
+ - chetan@pixelcop.net
49
+ executables: []
50
+ extensions: []
51
+ extra_rdoc_files: []
52
+ files:
53
+ - lib/sprockets-jst-str/engine.rb
54
+ - lib/sprockets-jst-str/str_template.rb
55
+ - lib/sprockets-jst-str/version.rb
56
+ - lib/sprockets-jst-str.rb
57
+ homepage: https://github.com/chetan/sprockets-jst-str
58
+ licenses: []
59
+ post_install_message:
60
+ rdoc_options: []
61
+ require_paths:
62
+ - lib
63
+ required_ruby_version: !ruby/object:Gem::Requirement
64
+ none: false
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ required_rubygems_version: !ruby/object:Gem::Requirement
70
+ none: false
71
+ requirements:
72
+ - - ! '>='
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ requirements: []
76
+ rubyforge_project:
77
+ rubygems_version: 1.8.25
78
+ signing_key:
79
+ specification_version: 3
80
+ summary: Slurps template into a JavaScript string for use with Sprockets JST functionality
81
+ test_files: []
82
+ has_rdoc: