js_erb 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +13 -2
- data/lib/js_erb/controller.rb +3 -3
- data/lib/js_erb/version.rb +1 -1
- metadata +3 -3
data/README.rdoc
CHANGED
@@ -40,14 +40,25 @@ inside the yml file (e.g. <%= var %>).
|
|
40
40
|
|
41
41
|
At the end set javascript_include_tag (add javascript files into the <head>).
|
42
42
|
|
43
|
-
==
|
43
|
+
== Javascript HTML Templates & Translations
|
44
|
+
|
45
|
+
JsErb will, in addition to javascript source files, create a javascript file with translations
|
46
|
+
and javascript file with HTML templates. You can access them in anywhere in your javascript like
|
47
|
+
|
48
|
+
# Access transations
|
49
|
+
alert( i18n.t('welcome') );
|
50
|
+
|
51
|
+
# Access template
|
52
|
+
alert( jserb.v('users.user') );
|
53
|
+
|
54
|
+
== JsErb With Jammit
|
44
55
|
|
45
56
|
Best practice is to use a packager to optimize project's javascript and stylesheets. You can
|
46
57
|
easily connect JsErb plugin with {Jammit}[http://documentcloud.github.com/jammit/] assets
|
47
58
|
packager. To integrate JsErb with Jammit you simply define JsErb's generated compiled files
|
48
59
|
(at RAILS/public/javascripts/compiled) in to Jammit's assets.yml file.
|
49
60
|
|
50
|
-
== JsErb
|
61
|
+
== JsErb Caching
|
51
62
|
|
52
63
|
The plugin will always compile files in the development or testing environment. In other
|
53
64
|
environments (e.g. production) it will compile files only if the compiled directory is
|
data/lib/js_erb/controller.rb
CHANGED
@@ -54,9 +54,9 @@ module JsErb
|
|
54
54
|
def compile_locales
|
55
55
|
Dir.glob("#{JsErb.config['path']['locales']}/*.js.yml").each do |file|
|
56
56
|
name = File.basename(file, '.js.yml')
|
57
|
-
content = YAML.load(ERB.new(File.read(file)).result)
|
57
|
+
content = YAML.load(ERB.new(File.read(file)).result)
|
58
58
|
File.open(File.join(JsErb.config['path']['compiled'], 'locales', "#{name}.js"), "wb") do |f|
|
59
|
-
f.write("var i18n
|
59
|
+
f.write("window.i18n = {t:function(key){for(var i in i18n.$){return i18n.$[i][key]}}, $:#{content.to_json} };")
|
60
60
|
end
|
61
61
|
end
|
62
62
|
end
|
@@ -84,7 +84,7 @@ module JsErb
|
|
84
84
|
end
|
85
85
|
|
86
86
|
File.open(File.join(JsErb.config['path']['compiled'], 'views', 'jserb.js'), "wb") do |f|
|
87
|
-
f.write("
|
87
|
+
f.write("window.jserb = { v:function(key){return jserb.$[key]}, $:#{list.to_json} };")
|
88
88
|
end
|
89
89
|
end
|
90
90
|
|
data/lib/js_erb/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: js_erb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 1
|
10
|
+
version: 0.1.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Kristijan Sedlak
|