jt-partial 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/jt-partial/haml_toolkit.rb +5 -0
- data/lib/jt-partial/js.rb +17 -0
- data/lib/jt-partial/page_context.rb +8 -0
- data/lib/jt-partial/partial.rb +12 -0
- data/lib/jt-partial/version.rb +1 -1
- data/lib/jt-partial.rb +4 -38
- metadata +7 -3
- /data/lib/{_js_script_tag.haml → jt-partial/_js_script_tag.haml} +0 -0
@@ -0,0 +1,17 @@
|
|
1
|
+
#js
|
2
|
+
def base_js(file)
|
3
|
+
is_base_file = file.include?( "application.js" ) || file.include?("pages.js")
|
4
|
+
is_base_file
|
5
|
+
end
|
6
|
+
|
7
|
+
def include_js
|
8
|
+
template_path = File.expand_path('../', __FILE__)
|
9
|
+
template = ""
|
10
|
+
Dir.glob "js/*.js" do |file|
|
11
|
+
if ! base_js file
|
12
|
+
template += haml_render "#{template_path}/_js_script_tag.haml", {js_file_path: file}
|
13
|
+
end
|
14
|
+
end
|
15
|
+
template += haml_render "#{template_path}/_js_script_tag.haml", {js_file_path: "js/pages.js"}
|
16
|
+
template
|
17
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
#partial
|
2
|
+
def render(partial)
|
3
|
+
partial_path = "_#{partial}.haml"
|
4
|
+
haml_render(partial_path)
|
5
|
+
end
|
6
|
+
|
7
|
+
def generate(template_name)
|
8
|
+
template_path = "_#{template_name}.haml"
|
9
|
+
output = haml_render(template_path)
|
10
|
+
html_page = File.new("#{template_name}.html", "w")
|
11
|
+
html_page.write(output)
|
12
|
+
end
|
data/lib/jt-partial/version.rb
CHANGED
data/lib/jt-partial.rb
CHANGED
@@ -1,40 +1,6 @@
|
|
1
1
|
require "jt-partial/version"
|
2
|
-
require "haml"
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
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
|
30
|
-
def render(partial)
|
31
|
-
partial_path = "_#{partial}.haml"
|
32
|
-
haml_render(partial_path)
|
33
|
-
end
|
34
|
-
|
35
|
-
def generate(template_name)
|
36
|
-
template_path = "_#{template_name}.haml"
|
37
|
-
output = haml_render(template_path)
|
38
|
-
html_page = File.new("#{template_name}.html", "w")
|
39
|
-
html_page.write(output)
|
40
|
-
end
|
3
|
+
require "jt-partial/haml_toolkit.rb"
|
4
|
+
require "jt-partial/js.rb"
|
5
|
+
require "jt-partial/page_context.rb"
|
6
|
+
require "jt-partial/partial.rb"
|
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.3
|
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-19 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: generate one page application html
|
15
15
|
email:
|
@@ -24,8 +24,12 @@ files:
|
|
24
24
|
- README.md
|
25
25
|
- Rakefile
|
26
26
|
- jt-partial.gemspec
|
27
|
-
- lib/_js_script_tag.haml
|
28
27
|
- lib/jt-partial.rb
|
28
|
+
- lib/jt-partial/_js_script_tag.haml
|
29
|
+
- lib/jt-partial/haml_toolkit.rb
|
30
|
+
- lib/jt-partial/js.rb
|
31
|
+
- lib/jt-partial/page_context.rb
|
32
|
+
- lib/jt-partial/partial.rb
|
29
33
|
- lib/jt-partial/version.rb
|
30
34
|
homepage: ''
|
31
35
|
licenses: []
|
File without changes
|