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.
@@ -0,0 +1,5 @@
1
+ require "haml"
2
+ #haml toolkit
3
+ def haml_render(template_path, args = {})
4
+ Haml::Engine.new(File.read(template_path)).render Object.new, args
5
+ end
@@ -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,8 @@
1
+ #page_context
2
+ @@page_context = {}
3
+
4
+ def page page_name
5
+ @@page_context[:name] = page_name
6
+ page_path = "pages/_#{page_name}.haml"
7
+ haml_render page_path
8
+ 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
@@ -1,5 +1,5 @@
1
1
  module Jt
2
2
  module Partial
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.3"
4
4
  end
5
5
  end
data/lib/jt-partial.rb CHANGED
@@ -1,40 +1,6 @@
1
1
  require "jt-partial/version"
2
- require "haml"
3
2
 
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
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.2
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-18 00:00:00.000000000 Z
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: []