templette 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,2 +1,3 @@
1
1
  # A site root can be set like this
2
2
  # Templette::config[:site_root] = '/new_root/'
3
+ # Templette::config[:default_engine] = 'haml' # The default is 'erb'
@@ -7,7 +7,7 @@ end
7
7
  module Templette
8
8
  CONFIG_FILE_PATH = 'config.rb'
9
9
 
10
- @@config = {:site_root => '/' }
10
+ @@config = {:site_root => '/', :default_engine => 'erb' }
11
11
 
12
12
  def self.config
13
13
  @@config
@@ -21,7 +21,7 @@ module Templette
21
21
  end
22
22
 
23
23
  def self.determine_type(filename)
24
- filename.match(/html\.?(\w+)?/)[1] || 'erb'
24
+ filename.match(/html\.?(\w+)?/)[1] || Templette::config[:default_engine]
25
25
  end
26
26
 
27
27
  private
@@ -21,14 +21,14 @@ module Templette
21
21
  "<img src='#{tag_path(path, 'images')}' #{params_to_attributes(options)}/>"
22
22
  end
23
23
 
24
- # Generates a link to a stylesheet. Default options {:type => 'text/css'}
24
+ # Generates a link to a stylesheet. Default options {:type => 'text/css', :rel => 'stylesheet'}
25
25
  #
26
26
  # Ex.
27
27
  # stylesheet_tag('print', :media => 'print')
28
28
  # => "<link href='/stylesheets/print.css' media='print' type='text/css' />"
29
29
 
30
30
  def stylesheet_tag(path, options = {})
31
- options = {:type => 'text/css'}.merge(options)
31
+ options = {:type => 'text/css', :rel => 'stylesheet', :media => 'screen'}.merge(options)
32
32
  "<link href='#{tag_path(path, 'stylesheets', 'css')}' #{params_to_attributes(options)}/>"
33
33
  end
34
34
 
@@ -45,7 +45,7 @@ module Templette
45
45
  private
46
46
 
47
47
  def tag_path(path, asset_subdir, file_ext = nil)
48
- if path =~ /http:\/\//
48
+ if path =~ /https?:\/\//
49
49
  path
50
50
  else
51
51
  "#{Templette.config[:site_root]}#{asset_subdir}/#{path}#{ "."+file_ext if file_ext }"
@@ -1,7 +1,7 @@
1
1
  require 'erb'
2
2
 
3
3
  module Templette
4
- # Loads a template and evaluates it with ERB. When a missing method is found,
4
+ # Loads a template and evaluates it. When a missing method is found,
5
5
  # MethodColletor loads that method into a hash, to be rendered as yaml.
6
6
  class MethodCollector
7
7
  include Templette::DataAccessors
@@ -15,8 +15,9 @@ module Templette
15
15
  # The <tt>template_name</tt> will be used to load a template.
16
16
  #
17
17
  # Everything in <tt>sections</tt> will be made available as methods in the template when
18
- # it's evaluated by ERB. Yaml hash items nested within others will be loaded into nested
19
- # objects. To call the nav title, the template should call <tt>nav.title</tt>.
18
+ # it's evaluated by by the rendering engine (ERB by default). Yaml hash items nested
19
+ # within others will be loaded into nested objects. To call the nav title, the template
20
+ # should call <tt>nav.title</tt>.
20
21
 
21
22
  class Page
22
23
 
@@ -61,7 +62,9 @@ module Templette
61
62
  end
62
63
  end
63
64
 
64
- def _binding; binding; end
65
+ def _binding # :nodoc:
66
+ binding
67
+ end
65
68
 
66
69
  # A requriement of the Templette::DataAccessors interface. Returns self.
67
70
  def page; self end
@@ -15,8 +15,9 @@ module Templette
15
15
 
16
16
  # The name parameter refers to the actual filename of the template. To load
17
17
  # templates/foo.html, a template_name of 'foo' should be given.
18
- def initialize(name)
19
- @name = name
18
+ def initialize(name, default_engine = Templette::config[:default_engine])
19
+ @name = name
20
+ @default_engine = default_engine
20
21
  end
21
22
 
22
23
  # Generates the yaml necessary to render empty page yaml files.
@@ -44,7 +45,7 @@ module Templette
44
45
  end
45
46
 
46
47
  def type
47
- path.match(/html\.?(\w+)?/)[1] || 'erb'
48
+ path.match(/html\.?(\w+)?/)[1] || @default_engine
48
49
  end
49
50
 
50
51
  def to_html
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: templette
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jacob Dunphy and Steve Holder
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-02-23 00:00:00 -08:00
12
+ date: 2009-02-27 00:00:00 -08:00
13
13
  default_executable: templette
14
14
  dependencies: []
15
15