fancyviews 1.4.0 → 1.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.4.0
1
+ 1.4.2
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{fancyviews}
8
- s.version = "1.4.0"
8
+ s.version = "1.4.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Myles Byrne"]
12
- s.date = %q{2009-11-11}
12
+ s.date = %q{2009-12-16}
13
13
  s.email = %q{myles@myles.id.au}
14
14
  s.extra_rdoc_files = [
15
15
  "README.markdown"
@@ -3,7 +3,7 @@ require 'haml'
3
3
  require 'sass'
4
4
 
5
5
  module Sinatra
6
-
6
+
7
7
  module StyleFilter
8
8
  include Haml::Filters::Base
9
9
 
@@ -12,7 +12,7 @@ module Sinatra
12
12
  end
13
13
  end
14
14
  Haml::Filters.defined['style'] = StyleFilter
15
-
15
+
16
16
  module ScriptFilter
17
17
  include Haml::Filters::Base
18
18
 
@@ -21,24 +21,24 @@ module Sinatra
21
21
  end
22
22
  end
23
23
  Haml::Filters.defined['script'] = ScriptFilter
24
-
24
+
25
25
  class FancyViews
26
-
26
+
27
27
  # current view
28
28
  attr_accessor :view_name
29
-
29
+
30
30
  def initialize(app)
31
31
  @app = app
32
32
  end
33
-
33
+
34
34
  def include_style(name, sass)
35
35
  included_styles << [name, sass] unless included_styles.detect { |s| s == [name, sass] }
36
36
  end
37
-
37
+
38
38
  def included_styles
39
39
  @included_styles ||= []
40
40
  end
41
-
41
+
42
42
  def include_script(name, js)
43
43
  included_scripts << [name, js] unless included_scripts.detect { |s| s == [name, js] }
44
44
  end
@@ -46,11 +46,11 @@ module Sinatra
46
46
  def included_scripts
47
47
  @included_scripts ||= []
48
48
  end
49
-
49
+
50
50
  end
51
-
51
+
52
52
  module FancyHelpers
53
-
53
+
54
54
  # use this instead of `haml` when rendering a template, unlike the haml
55
55
  # method, layout is false by default
56
56
  def view(name, options = {})
@@ -61,23 +61,22 @@ module Sinatra
61
61
  fancyviews.view_name = parent_view
62
62
  rendered
63
63
  end
64
-
64
+
65
65
  # same as `view` but has layout by default
66
66
  def page(name, options = {})
67
67
  options[:layout] = true unless options.has_key?(:layout)
68
68
  view(name, options)
69
69
  end
70
-
70
+
71
71
  # renders all the styles captured by the :style filter
72
72
  def styles(options = {})
73
73
  imported = if options[:import]
74
74
  [*options[:import]].map { |name| File.read("#{self.options.views}/#{name}.sass") }.join("\n")
75
75
  end
76
76
 
77
- rendered_styles = fancyviews.included_styles.map do |name, sass|
77
+ rendered_styles = fancyviews.included_styles.map do |name, sass|
78
78
  # would be nice if construction took an :offest to go along with the :filename
79
79
  eng = Sass::Engine.new((imported || '') + "\n" + sass,
80
- :attribute_syntax => :normal,
81
80
  :load_paths => [self.options.views])
82
81
  "\n/* -- #{name} -- */\n" + eng.render
83
82
  end.join
@@ -97,7 +96,7 @@ module Sinatra
97
96
  "\n/* -- #{name} -- */\n" + js
98
97
  end.join)
99
98
  end
100
-
99
+
101
100
  def script_tag(scripts)
102
101
  capture_haml do
103
102
  haml_tag(:script, scripts, :type => ("text/javascript" if haml_format != :html5))
@@ -105,13 +104,13 @@ module Sinatra
105
104
  end
106
105
 
107
106
  def haml_format
108
- (options.haml && options.haml[:format]) || :xhtml
107
+ (options.member?(:haml) && options.haml[:format]) || :xhtml
109
108
  end
110
-
109
+
111
110
  def fancyviews
112
111
  @fancyviews ||= FancyViews.new(self)
113
112
  end
114
-
113
+
115
114
  end
116
115
 
117
116
  helpers FancyHelpers
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fancyviews
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Myles Byrne
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-11-11 00:00:00 +11:00
12
+ date: 2009-12-16 00:00:00 +11:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency