whtml_sprockets 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/init.rb +1 -0
- data/lib/whtml_sprockets/engine.rb +8 -0
- data/lib/whtml_sprockets/processor.rb +40 -0
- data/lib/whtml_sprockets.rb +10 -0
- metadata +60 -0
data/init.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'whtml_sprockets'
|
@@ -0,0 +1,40 @@
|
|
1
|
+
puts "yeah processor"
|
2
|
+
|
3
|
+
module WHTMLSprockets
|
4
|
+
class Processor < Tilt::Template
|
5
|
+
JS_ESCAPE_MAP = {
|
6
|
+
'\\' => '\\\\',
|
7
|
+
'</' => '<\/',
|
8
|
+
"\r\n" => '\n',
|
9
|
+
"\n" => '\n',
|
10
|
+
"\r" => '\n',
|
11
|
+
'"' => '\\"',
|
12
|
+
"'" => "\\'"
|
13
|
+
}
|
14
|
+
|
15
|
+
def self.default_mime_type
|
16
|
+
'application/javascript'
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.default_namespace
|
20
|
+
'this.Wingman.View.template_sources'
|
21
|
+
end
|
22
|
+
|
23
|
+
def prepare
|
24
|
+
@namespace = self.class.default_namespace
|
25
|
+
end
|
26
|
+
|
27
|
+
attr_reader :namespace
|
28
|
+
|
29
|
+
def evaluate(scope, locals, &block)
|
30
|
+
escaped = data.gsub(/(\\|<\/|\r\n|\342\200\250|[\n\r"'])/u) {|match| JS_ESCAPE_MAP[match] }
|
31
|
+
|
32
|
+
<<-JS
|
33
|
+
(function() {
|
34
|
+
#{namespace} || (#{namespace} = {});
|
35
|
+
#{namespace}[#{scope.logical_path.inspect}] = '#{escaped}';
|
36
|
+
}).call(this);
|
37
|
+
JS
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
metadata
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: whtml_sprockets
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Rasmus Rønn Nielsen
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-03-21 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: sprockets
|
16
|
+
requirement: &70365393113580 !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: *70365393113580
|
25
|
+
description: whtml_sprockets exposes your WHTML templates to the browser throught
|
26
|
+
Sprockets.
|
27
|
+
email: rasmusrnielsen@gmail.com
|
28
|
+
executables: []
|
29
|
+
extensions: []
|
30
|
+
extra_rdoc_files: []
|
31
|
+
files:
|
32
|
+
- lib/whtml_sprockets/engine.rb
|
33
|
+
- lib/whtml_sprockets/processor.rb
|
34
|
+
- lib/whtml_sprockets.rb
|
35
|
+
- init.rb
|
36
|
+
homepage: http://rrn.dk
|
37
|
+
licenses: []
|
38
|
+
post_install_message:
|
39
|
+
rdoc_options: []
|
40
|
+
require_paths:
|
41
|
+
- lib
|
42
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
43
|
+
none: false
|
44
|
+
requirements:
|
45
|
+
- - ! '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
requirements: []
|
55
|
+
rubyforge_project:
|
56
|
+
rubygems_version: 1.8.10
|
57
|
+
signing_key:
|
58
|
+
specification_version: 3
|
59
|
+
summary: WHTML template handler for Sprockets.
|
60
|
+
test_files: []
|