jt-partial 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/_js_script_tag.haml +1 -0
- data/lib/jt-partial/version.rb +1 -1
- data/lib/jt-partial.rb +30 -4
- metadata +3 -2
@@ -0,0 +1 @@
|
|
1
|
+
%script(type="text/javascript" src="#{js_file_path}")
|
data/lib/jt-partial/version.rb
CHANGED
data/lib/jt-partial.rb
CHANGED
@@ -1,14 +1,40 @@
|
|
1
1
|
require "jt-partial/version"
|
2
2
|
require "haml"
|
3
3
|
|
4
|
+
#js
|
5
|
+
|
6
|
+
def base_js(file)
|
7
|
+
is_base_file = file.include?( "application.js" ) || file.include?("pages.js")
|
8
|
+
puts file
|
9
|
+
puts is_base_file
|
10
|
+
is_base_file
|
11
|
+
end
|
12
|
+
|
13
|
+
def include_js
|
14
|
+
template_path = File.expand_path('../', __FILE__)
|
15
|
+
template = ""
|
16
|
+
Dir.glob "js/*.js" do |file|
|
17
|
+
if ! base_js file
|
18
|
+
template += haml_render "#{template_path}/_js_script_tag.haml", {js_file_path: file}
|
19
|
+
end
|
20
|
+
end
|
21
|
+
template += haml_render "#{template_path}/_js_script_tag.haml", {js_file_path: "js/pages.js"}
|
22
|
+
template
|
23
|
+
end
|
24
|
+
|
25
|
+
def haml_render(template_path, args = {})
|
26
|
+
Haml::Engine.new(File.read(template_path)).render Object.new, args
|
27
|
+
end
|
28
|
+
|
29
|
+
#partial
|
4
30
|
def render(partial)
|
5
|
-
|
31
|
+
partial_path = "_#{partial}.haml"
|
32
|
+
haml_render(partial_path)
|
6
33
|
end
|
7
34
|
|
8
35
|
def generate(template_name)
|
9
|
-
|
10
|
-
|
11
|
-
output = haml_engine.render
|
36
|
+
template_path = "_#{template_name}.haml"
|
37
|
+
output = haml_render(template_path)
|
12
38
|
html_page = File.new("#{template_name}.html", "w")
|
13
39
|
html_page.write(output)
|
14
40
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jt-partial
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-11-
|
12
|
+
date: 2012-11-18 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: generate one page application html
|
15
15
|
email:
|
@@ -24,6 +24,7 @@ files:
|
|
24
24
|
- README.md
|
25
25
|
- Rakefile
|
26
26
|
- jt-partial.gemspec
|
27
|
+
- lib/_js_script_tag.haml
|
27
28
|
- lib/jt-partial.rb
|
28
29
|
- lib/jt-partial/version.rb
|
29
30
|
homepage: ''
|