sinatra_more 0.0.9 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
@@ -59,23 +59,43 @@ methods should be very familiar to anyone who has used rails view helpers.
59
59
  * Captures the html from a block of template code for erb or haml
60
60
  * capture_html(&block) => "...html..."
61
61
  * concat_content(text="")
62
- * Outputs the given text to the templates buffer directly
62
+ * Outputs the given text to the templates buffer directly in erb or haml
63
63
  * concat_content("This will be output to the template buffer in erb or haml")
64
64
 
65
65
  ==== Tag Helpers
66
66
 
67
67
  * tag(name, options={})
68
+ * Creates an html tag with the given name and options
69
+ * tag(:br, :style => 'clear:both') => <br style="clear:both" />
70
+ * tag(:p, :content => "demo", :class => 'large') => <p class="large">demo</p>
68
71
  * content_tag(name, content, options={})
72
+ * Creates an html tag with given name, content and options
73
+ * content_tag(:p, "demo", :class => 'light') => <p class="light">demo</p>
74
+ * content_tag(:p, :class => 'dark') { ...content... } => <p class="dark">...content...</p>
69
75
  * input_tag(type, options = {})
76
+ * Creates an html input field with given type and options
77
+ * input_tag :text, :class => "demo"
78
+ * input_tag :password, :value => "secret", :class => "demo"
70
79
 
71
80
  ==== Asset Helpers
72
81
 
73
82
  * flash_tag(kind, options={})
83
+ * Creates a div to display the flash of given type if it exists
84
+ * flash_tag(:notice, :class => 'flash', :id => 'flash-notice')
74
85
  * link_to(*args, &block)
86
+ * Creates a link element with given name, url and options
87
+ * link_to 'click me', '/dashboard', :class => 'linky'
88
+ * link_to('/dashboard', :class => 'blocky') { ...content... }
75
89
  * image_tag(url, options={})
90
+ * Creates an image element with given url and options
91
+ * image_tag('icons/avatar.png')
76
92
  * stylesheet_link_tag(*sources)
93
+ * Returns a stylesheet link tag for the sources specified as arguments
94
+ * stylesheet_link_tag 'style', 'application', 'layout'
77
95
  * javascript_include_tag(*sources)
78
-
96
+ * Returns an html script tag for each of the sources provided.
97
+ * javascript_include_tag 'application', 'special'
98
+
79
99
  ==== Form Helpers
80
100
 
81
101
  * form_for(object, url, settings={}, &block)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.9
1
+ 0.0.10
@@ -1,6 +1,7 @@
1
1
  module SinatraMore
2
2
  module AssetTagHelpers
3
3
 
4
+ # Creates a div to display the flash of given type if it exists
4
5
  # flash_tag(:notice, :class => 'flash', :id => 'flash-notice')
5
6
  def flash_tag(kind, options={})
6
7
  flash_text = flash[kind]
@@ -9,7 +10,9 @@ module SinatraMore
9
10
  content_tag(:div, flash_text, options)
10
11
  end
11
12
 
13
+ # Creates a link element with given name, url and options
12
14
  # link_to 'click me', '/dashboard', :class => 'linky'
15
+ # link_to('/dashboard', :class => 'blocky') do ... end
13
16
  # parameters: name, url='javascript:void(0)', options={}, &block
14
17
  def link_to(*args, &block)
15
18
  if block_given?
@@ -24,12 +27,14 @@ module SinatraMore
24
27
  end
25
28
  end
26
29
 
30
+ # Creates an image element with given url and options
27
31
  # image_tag('icons/avatar.png')
28
32
  def image_tag(url, options={})
29
33
  options.reverse_merge!(:src => url)
30
34
  tag(:img, options)
31
35
  end
32
36
 
37
+ # Returns a stylesheet link tag for the sources specified as arguments
33
38
  # stylesheet_link_tag 'style', 'application', 'layout'
34
39
  def stylesheet_link_tag(*sources)
35
40
  options = sources.extract_options!.symbolize_keys
@@ -30,9 +30,9 @@ module SinatraMore
30
30
  return "" if record.blank? or record.errors.none?
31
31
  options.reverse_merge!(:header_message => "The #{record.class.to_s.downcase} could not be saved!")
32
32
  error_messages = record.errors.full_messages
33
- content_block_tag(:div, :class => 'field-errors') do
33
+ content_block_tag(:div, :class => 'field-errors', :concat => false) do
34
34
  html = content_tag(:p, options.delete(:header_message))
35
- html << content_block_tag(:ul, :class => 'field-errors') do
35
+ html << content_block_tag(:ul, :class => 'field-errors', :concat => false) do
36
36
  error_messages.collect { |er| content_tag(:li, er) }.join("\n")
37
37
  end
38
38
  end
@@ -1,11 +1,13 @@
1
1
  module SinatraMore
2
2
  module TagHelpers
3
+ # Creates an html input field with given type and options
3
4
  # input_tag :text, :class => "test"
4
5
  def input_tag(type, options = {})
5
6
  options.reverse_merge!(:type => type)
6
7
  tag(:input, options)
7
8
  end
8
9
 
10
+ # Creates an html tag with given name, content and options
9
11
  # content_tag(:p, "hello", :class => 'light')
10
12
  # content_tag(:p, :class => 'dark') do ... end
11
13
  # parameters: content_tag(name, content=nil, options={})
@@ -21,6 +23,7 @@ module SinatraMore
21
23
  end
22
24
  alias content_block_tag content_tag
23
25
 
26
+ # Creates an html tag with the given name and options
24
27
  # tag(:br, :style => 'clear:both')
25
28
  # tag(:p, :content => "hello", :class => 'large')
26
29
  def tag(name, options={})
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{sinatra_more}
8
- s.version = "0.0.9"
8
+ s.version = "0.0.10"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Nathan Esquenazi"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinatra_more
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Esquenazi