markaby 0.3 → 0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. data/Rakefile +1 -1
  2. data/lib/markaby.rb +2 -2
  3. data/lib/markaby/builder.rb +57 -33
  4. data/lib/markaby/tags.rb +1 -0
  5. data/test/test_markaby.rb +21 -16
  6. metadata +4 -63
  7. data/doc/rdoc/classes/Markaby.html +0 -192
  8. data/doc/rdoc/classes/Markaby/ActionControllerHelper.html +0 -145
  9. data/doc/rdoc/classes/Markaby/ActionControllerHelper.src/M000005.html +0 -20
  10. data/doc/rdoc/classes/Markaby/Builder.html +0 -480
  11. data/doc/rdoc/classes/Markaby/Builder.src/M000008.html +0 -44
  12. data/doc/rdoc/classes/Markaby/Builder.src/M000009.html +0 -18
  13. data/doc/rdoc/classes/Markaby/Builder.src/M000010.html +0 -19
  14. data/doc/rdoc/classes/Markaby/Builder.src/M000012.html +0 -24
  15. data/doc/rdoc/classes/Markaby/Builder.src/M000013.html +0 -18
  16. data/doc/rdoc/classes/Markaby/Builder.src/M000014.html +0 -22
  17. data/doc/rdoc/classes/Markaby/Builder.src/M000015.html +0 -38
  18. data/doc/rdoc/classes/Markaby/Builder.src/M000016.html +0 -18
  19. data/doc/rdoc/classes/Markaby/Builder.src/M000017.html +0 -18
  20. data/doc/rdoc/classes/Markaby/Builder.src/M000018.html +0 -21
  21. data/doc/rdoc/classes/Markaby/Builder.src/M000019.html +0 -24
  22. data/doc/rdoc/classes/Markaby/Builder.src/M000021.html +0 -18
  23. data/doc/rdoc/classes/Markaby/CssProxy.html +0 -177
  24. data/doc/rdoc/classes/Markaby/CssProxy.src/M000006.html +0 -19
  25. data/doc/rdoc/classes/Markaby/CssProxy.src/M000007.html +0 -33
  26. data/doc/rdoc/classes/Markaby/Template.html +0 -156
  27. data/doc/rdoc/classes/Markaby/Template.src/M000022.html +0 -18
  28. data/doc/rdoc/classes/Markaby/Template.src/M000023.html +0 -20
  29. data/doc/rdoc/classes/Markaby/View.html +0 -156
  30. data/doc/rdoc/classes/Markaby/View.src/M000024.html +0 -18
  31. data/doc/rdoc/classes/Markaby/View.src/M000025.html +0 -18
  32. data/doc/rdoc/classes/Object.html +0 -199
  33. data/doc/rdoc/classes/Object.src/M000001.html +0 -16
  34. data/doc/rdoc/classes/Object.src/M000002.html +0 -16
  35. data/doc/rdoc/classes/Object.src/M000003.html +0 -18
  36. data/doc/rdoc/classes/Object.src/M000004.html +0 -18
  37. data/doc/rdoc/created.rid +0 -1
  38. data/doc/rdoc/files/CHANGELOG.html +0 -136
  39. data/doc/rdoc/files/README.html +0 -326
  40. data/doc/rdoc/files/lib/markaby/builder_rb.html +0 -101
  41. data/doc/rdoc/files/lib/markaby/cssproxy_rb.html +0 -101
  42. data/doc/rdoc/files/lib/markaby/helper_rb.html +0 -101
  43. data/doc/rdoc/files/lib/markaby/metaid_rb.html +0 -107
  44. data/doc/rdoc/files/lib/markaby/tags_rb.html +0 -101
  45. data/doc/rdoc/files/lib/markaby/template_rb.html +0 -101
  46. data/doc/rdoc/files/lib/markaby/view_rb.html +0 -101
  47. data/doc/rdoc/files/lib/markaby_rb.html +0 -127
  48. data/doc/rdoc/fr_class_index.html +0 -33
  49. data/doc/rdoc/fr_file_index.html +0 -36
  50. data/doc/rdoc/fr_method_index.html +0 -51
  51. data/doc/rdoc/index.html +0 -24
  52. data/doc/rdoc/rdoc-style.css +0 -208
  53. data/test/example.rb +0 -48
@@ -1,199 +0,0 @@
1
- <?xml version="1.0" encoding="iso-8859-1"?>
2
- <!DOCTYPE html
3
- PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
-
6
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
- <head>
8
- <title>Class: Object</title>
9
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
- <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
- <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
12
- <script type="text/javascript">
13
- // <![CDATA[
14
-
15
- function popupCode( url ) {
16
- window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
- }
18
-
19
- function toggleCode( id ) {
20
- if ( document.getElementById )
21
- elem = document.getElementById( id );
22
- else if ( document.all )
23
- elem = eval( "document.all." + id );
24
- else
25
- return false;
26
-
27
- elemStyle = elem.style;
28
-
29
- if ( elemStyle.display != "block" ) {
30
- elemStyle.display = "block"
31
- } else {
32
- elemStyle.display = "none"
33
- }
34
-
35
- return true;
36
- }
37
-
38
- // Make codeblocks hidden by default
39
- document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
-
41
- // ]]>
42
- </script>
43
-
44
- </head>
45
- <body>
46
-
47
-
48
-
49
- <div id="classHeader">
50
- <table class="header-table">
51
- <tr class="top-aligned-row">
52
- <td><strong>Class</strong></td>
53
- <td class="class-name-in-header">Object</td>
54
- </tr>
55
- <tr class="top-aligned-row">
56
- <td><strong>In:</strong></td>
57
- <td>
58
- <a href="../files/lib/markaby/metaid_rb.html">
59
- lib/markaby/metaid.rb
60
- </a>
61
- <br />
62
- </td>
63
- </tr>
64
-
65
- <tr class="top-aligned-row">
66
- <td><strong>Parent:</strong></td>
67
- <td>
68
- <a href="Object.html">
69
- Object
70
- </a>
71
- </td>
72
- </tr>
73
- </table>
74
- </div>
75
- <!-- banner header -->
76
-
77
- <div id="bodyContent">
78
-
79
-
80
-
81
- <div id="contextContent">
82
-
83
- <div id="description">
84
- <p>
85
- metaprogramming assistant &#8212; metaid.rb
86
- </p>
87
-
88
- </div>
89
-
90
-
91
- </div>
92
-
93
- <div id="method-list">
94
- <h3 class="section-bar">Methods</h3>
95
-
96
- <div class="name-list">
97
- <a href="#M000004">class_def</a>&nbsp;&nbsp;
98
- <a href="#M000003">meta_def</a>&nbsp;&nbsp;
99
- <a href="#M000002">meta_eval</a>&nbsp;&nbsp;
100
- <a href="#M000001">metaclass</a>&nbsp;&nbsp;
101
- </div>
102
- </div>
103
-
104
- </div>
105
-
106
-
107
- <!-- if includes -->
108
-
109
- <div id="section">
110
-
111
-
112
-
113
-
114
-
115
-
116
-
117
-
118
- <!-- if method_list -->
119
- <div id="methods">
120
- <h3 class="section-bar">Public Instance methods</h3>
121
-
122
- <div id="method-M000004" class="method-detail">
123
- <a name="M000004"></a>
124
-
125
- <div class="method-heading">
126
- <a href="Object.src/M000004.html" target="Code" class="method-signature"
127
- onclick="popupCode('Object.src/M000004.html');return false;">
128
- <span class="method-name">class_def</span><span class="method-args">(name, &amp;blk)</span>
129
- </a>
130
- </div>
131
-
132
- <div class="method-description">
133
- <p>
134
- Defines an instance method within a class
135
- </p>
136
- </div>
137
- </div>
138
-
139
- <div id="method-M000003" class="method-detail">
140
- <a name="M000003"></a>
141
-
142
- <div class="method-heading">
143
- <a href="Object.src/M000003.html" target="Code" class="method-signature"
144
- onclick="popupCode('Object.src/M000003.html');return false;">
145
- <span class="method-name">meta_def</span><span class="method-args">(name, &amp;blk)</span>
146
- </a>
147
- </div>
148
-
149
- <div class="method-description">
150
- <p>
151
- Adds methods to a metaclass
152
- </p>
153
- </div>
154
- </div>
155
-
156
- <div id="method-M000002" class="method-detail">
157
- <a name="M000002"></a>
158
-
159
- <div class="method-heading">
160
- <a href="Object.src/M000002.html" target="Code" class="method-signature"
161
- onclick="popupCode('Object.src/M000002.html');return false;">
162
- <span class="method-name">meta_eval</span><span class="method-args">(&amp;blk;)</span>
163
- </a>
164
- </div>
165
-
166
- <div class="method-description">
167
- </div>
168
- </div>
169
-
170
- <div id="method-M000001" class="method-detail">
171
- <a name="M000001"></a>
172
-
173
- <div class="method-heading">
174
- <a href="Object.src/M000001.html" target="Code" class="method-signature"
175
- onclick="popupCode('Object.src/M000001.html');return false;">
176
- <span class="method-name">metaclass</span><span class="method-args">()</span>
177
- </a>
178
- </div>
179
-
180
- <div class="method-description">
181
- <p>
182
- The hidden singleton lurks behind everyone
183
- </p>
184
- </div>
185
- </div>
186
-
187
-
188
- </div>
189
-
190
-
191
- </div>
192
-
193
-
194
- <div id="validator-badges">
195
- <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
196
- </div>
197
-
198
- </body>
199
- </html>
@@ -1,16 +0,0 @@
1
- <?xml version="1.0" encoding="iso-8859-1"?>
2
- <!DOCTYPE html
3
- PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
-
6
- <html>
7
- <head>
8
- <title>metaclass (Object)</title>
9
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
- <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
11
- </head>
12
- <body class="standalone-code">
13
- <pre> <span class="ruby-comment cmt"># File lib/markaby/metaid.rb, line 4</span>
14
- 4: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">metaclass</span>; <span class="ruby-keyword kw">class</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-keyword kw">self</span>; <span class="ruby-keyword kw">self</span>; <span class="ruby-keyword kw">end</span>; <span class="ruby-keyword kw">end</span></pre>
15
- </body>
16
- </html>
@@ -1,16 +0,0 @@
1
- <?xml version="1.0" encoding="iso-8859-1"?>
2
- <!DOCTYPE html
3
- PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
-
6
- <html>
7
- <head>
8
- <title>meta_eval (Object)</title>
9
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
- <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
11
- </head>
12
- <body class="standalone-code">
13
- <pre> <span class="ruby-comment cmt"># File lib/markaby/metaid.rb, line 5</span>
14
- 5: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">meta_eval</span> <span class="ruby-operator">&amp;</span><span class="ruby-identifier">blk</span>; <span class="ruby-identifier">metaclass</span>.<span class="ruby-identifier">instance_eval</span> <span class="ruby-operator">&amp;</span><span class="ruby-identifier">blk</span>; <span class="ruby-keyword kw">end</span></pre>
15
- </body>
16
- </html>
@@ -1,18 +0,0 @@
1
- <?xml version="1.0" encoding="iso-8859-1"?>
2
- <!DOCTYPE html
3
- PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
-
6
- <html>
7
- <head>
8
- <title>meta_def (Object)</title>
9
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
- <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
11
- </head>
12
- <body class="standalone-code">
13
- <pre> <span class="ruby-comment cmt"># File lib/markaby/metaid.rb, line 8</span>
14
- 8: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">meta_def</span> <span class="ruby-identifier">name</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">blk</span>
15
- 9: <span class="ruby-identifier">meta_eval</span> { <span class="ruby-identifier">define_method</span> <span class="ruby-identifier">name</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">blk</span> }
16
- 10: <span class="ruby-keyword kw">end</span></pre>
17
- </body>
18
- </html>
@@ -1,18 +0,0 @@
1
- <?xml version="1.0" encoding="iso-8859-1"?>
2
- <!DOCTYPE html
3
- PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
-
6
- <html>
7
- <head>
8
- <title>class_def (Object)</title>
9
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
- <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
11
- </head>
12
- <body class="standalone-code">
13
- <pre> <span class="ruby-comment cmt"># File lib/markaby/metaid.rb, line 13</span>
14
- 13: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">class_def</span> <span class="ruby-identifier">name</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">blk</span>
15
- 14: <span class="ruby-identifier">class_eval</span> { <span class="ruby-identifier">define_method</span> <span class="ruby-identifier">name</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">blk</span> }
16
- 15: <span class="ruby-keyword kw">end</span></pre>
17
- </body>
18
- </html>
data/doc/rdoc/created.rid DELETED
@@ -1 +0,0 @@
1
- Wed Feb 01 22:53:39 MST 2006
@@ -1,136 +0,0 @@
1
- <?xml version="1.0" encoding="iso-8859-1"?>
2
- <!DOCTYPE html
3
- PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
-
6
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
- <head>
8
- <title>File: CHANGELOG</title>
9
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
- <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
- <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
12
- <script type="text/javascript">
13
- // <![CDATA[
14
-
15
- function popupCode( url ) {
16
- window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
- }
18
-
19
- function toggleCode( id ) {
20
- if ( document.getElementById )
21
- elem = document.getElementById( id );
22
- else if ( document.all )
23
- elem = eval( "document.all." + id );
24
- else
25
- return false;
26
-
27
- elemStyle = elem.style;
28
-
29
- if ( elemStyle.display != "block" ) {
30
- elemStyle.display = "block"
31
- } else {
32
- elemStyle.display = "none"
33
- }
34
-
35
- return true;
36
- }
37
-
38
- // Make codeblocks hidden by default
39
- document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
-
41
- // ]]>
42
- </script>
43
-
44
- </head>
45
- <body>
46
-
47
-
48
-
49
- <div id="fileHeader">
50
- <h1>CHANGELOG</h1>
51
- <table class="header-table">
52
- <tr class="top-aligned-row">
53
- <td><strong>Path:</strong></td>
54
- <td>CHANGELOG
55
- </td>
56
- </tr>
57
- <tr class="top-aligned-row">
58
- <td><strong>Last Update:</strong></td>
59
- <td>Wed Feb 01 21:36:52 MST 2006</td>
60
- </tr>
61
- </table>
62
- </div>
63
- <!-- banner header -->
64
-
65
- <div id="bodyContent">
66
-
67
-
68
-
69
- <div id="contextContent">
70
-
71
- <div id="description">
72
- <h1>0.3</h1>
73
- <h3>02nd February, 2006</h3>
74
- <ul>
75
- <li>Allow <a
76
- href="../classes/Markaby/Builder.html#M000008">Markaby::Builder.new</a>
77
- without args.
78
-
79
- </li>
80
- <li>Rails helper method render_markaby.
81
-
82
- </li>
83
- </ul>
84
- <h1>0.2</h1>
85
- <h3>17th January, 2006</h3>
86
- <ul>
87
- <li>Public announcement.
88
-
89
- </li>
90
- <li>DOCTYPES, head tags.
91
-
92
- </li>
93
- <li>Works with Rails helpers.
94
-
95
- </li>
96
- </ul>
97
- <h1>0.1</h1>
98
- <h3>05th January, 2006</h3>
99
- <ul>
100
- <li>Initial import.
101
-
102
- </li>
103
- </ul>
104
-
105
- </div>
106
-
107
-
108
- </div>
109
-
110
-
111
- </div>
112
-
113
-
114
- <!-- if includes -->
115
-
116
- <div id="section">
117
-
118
-
119
-
120
-
121
-
122
-
123
-
124
-
125
- <!-- if method_list -->
126
-
127
-
128
- </div>
129
-
130
-
131
- <div id="validator-badges">
132
- <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
133
- </div>
134
-
135
- </body>
136
- </html>
@@ -1,326 +0,0 @@
1
- <?xml version="1.0" encoding="iso-8859-1"?>
2
- <!DOCTYPE html
3
- PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
-
6
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
- <head>
8
- <title>File: README</title>
9
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
- <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
- <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
12
- <script type="text/javascript">
13
- // <![CDATA[
14
-
15
- function popupCode( url ) {
16
- window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
- }
18
-
19
- function toggleCode( id ) {
20
- if ( document.getElementById )
21
- elem = document.getElementById( id );
22
- else if ( document.all )
23
- elem = eval( "document.all." + id );
24
- else
25
- return false;
26
-
27
- elemStyle = elem.style;
28
-
29
- if ( elemStyle.display != "block" ) {
30
- elemStyle.display = "block"
31
- } else {
32
- elemStyle.display = "none"
33
- }
34
-
35
- return true;
36
- }
37
-
38
- // Make codeblocks hidden by default
39
- document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
-
41
- // ]]>
42
- </script>
43
-
44
- </head>
45
- <body>
46
-
47
-
48
-
49
- <div id="fileHeader">
50
- <h1>README</h1>
51
- <table class="header-table">
52
- <tr class="top-aligned-row">
53
- <td><strong>Path:</strong></td>
54
- <td>README
55
- </td>
56
- </tr>
57
- <tr class="top-aligned-row">
58
- <td><strong>Last Update:</strong></td>
59
- <td>Wed Feb 01 20:34:06 MST 2006</td>
60
- </tr>
61
- </table>
62
- </div>
63
- <!-- banner header -->
64
-
65
- <div id="bodyContent">
66
-
67
-
68
-
69
- <div id="contextContent">
70
-
71
- <div id="description">
72
- <h1><a href="../classes/Markaby.html">Markaby</a> (Markup as Ruby)</h1>
73
- <p>
74
- <a href="../classes/Markaby.html">Markaby</a> is a very short bit of code
75
- for writing HTML pages in pure Ruby. It is an alternative to ERb which
76
- weaves the two languages together. Also a replacement for templating
77
- languages which use primitive languages that blend with HTML.
78
- </p>
79
- <h2>Using <a href="../classes/Markaby.html">Markaby</a> as a Rails plugin</h2>
80
- <p>
81
- Write Rails templates in pure Ruby. Example layout:
82
- </p>
83
- <pre>
84
- html do
85
- head do
86
- title 'Products: ' + action_name
87
- stylesheet_link_tag 'scaffold'
88
- end
89
-
90
- body do
91
- p flash[:notice], :style =&gt; &quot;color: green&quot;
92
-
93
- self &lt;&lt; content_for_layout
94
- end
95
- end
96
- </pre>
97
- <h2>Using <a href="../classes/Markaby.html">Markaby</a> as a Ruby class</h2>
98
- <p>
99
- <a href="../classes/Markaby.html">Markaby</a> is flaming easy to call from
100
- your Ruby classes.
101
- </p>
102
- <pre>
103
- require 'markaby'
104
-
105
- mab = Markaby::Builder.new
106
- mab.html do
107
- head { title &quot;Boats.com&quot; }
108
- body do
109
- h1 &quot;Boats.com has great deals&quot;
110
- ul do
111
- li &quot;$49 for a canoe&quot;
112
- li &quot;$39 for a raft&quot;
113
- li &quot;$29 for a huge boot that floats and can fit 5 people&quot;
114
- end
115
- end
116
- end
117
- puts mab.to_s
118
- </pre>
119
- <p>
120
- <a href="../classes/Markaby/Builder.html#M000008">Markaby::Builder.new</a>
121
- does take two arguments for passing in variables and a helper object. You
122
- can also affix the block right on to the class.
123
- </p>
124
- <p>
125
- See <a href="../classes/Markaby/Builder.html">Markaby::Builder</a> for all
126
- of that.
127
- </p>
128
- <h1>A Note About <tt>instance_eval</tt></h1>
129
- <p>
130
- The <a href="../classes/Markaby/Builder.html">Markaby::Builder</a> class is
131
- different from the normal Builder class, since it uses
132
- <tt>instance_eval</tt> when running blocks. This cleans up the appearance
133
- of the <a href="../classes/Markaby.html">Markaby</a> code you write. If
134
- <tt>instance_eval</tt> was not used, the code would look like this:
135
- </p>
136
- <pre>
137
- mab = Markaby::Builder.new
138
- mab.html do
139
- mab.head { mab.title &quot;Boats.com&quot; }
140
- mab.body do
141
- mab.h1 &quot;Boats.com has great deals&quot;
142
- end
143
- end
144
- puts mab.to_s
145
- </pre>
146
- <p>
147
- So, the advantage is the cleanliness of your code. The disadvantage is that
148
- the block will run inside the <a
149
- href="../classes/Markaby/Builder.html">Markaby::Builder</a> object&#8217;s
150
- scope. This means that inside these blocks, <tt>self</tt> will be your <a
151
- href="../classes/Markaby/Builder.html">Markaby::Builder</a> object. When
152
- you use instance variables in these blocks, they will be instance variables
153
- of the <a href="../classes/Markaby/Builder.html">Markaby::Builder</a>
154
- object.
155
- </p>
156
- <p>
157
- This doesn&#8217;t effect Rails users, but when used in regular Ruby code,
158
- it can be a bit disorienting. You are recommended to put your <a
159
- href="../classes/Markaby.html">Markaby</a> code in a module where it
160
- won&#8217;t mix with anything.
161
- </p>
162
- <h1>A Note About Rails Helpers</h1>
163
- <p>
164
- When used in Rails templates, the Rails helper object is passed into <a
165
- href="../classes/Markaby/Builder.html">Markaby::Builder</a>. When you call
166
- helper methods inside <a href="../classes/Markaby.html">Markaby</a>, the
167
- output from those methods will be output to the stream. This is incredibly
168
- handy, since most Rails helpers output HTML tags.
169
- </p>
170
- <pre>
171
- head do
172
- javascript_include_tag 'prototype'
173
- autodiscovery_link_tag
174
- end
175
- </pre>
176
- <p>
177
- However, some methods are designed to give back a String which you can use
178
- elsewhere. Call the <tt>@helpers</tt> object with the method and
179
- you&#8217;ll get the String back and nothing will be output.
180
- </p>
181
- <pre>
182
- p &quot;Total is: #{@helper.number_to_human_size @file_bytes}&quot;
183
- </pre>
184
- <p>
185
- Conversely, you may call instance variables from your controller by using a
186
- method and its value will be returned, nothing will be output.
187
- </p>
188
- <pre>
189
- # Inside imaginary ProductController
190
- def list
191
- @products = Product.find :all
192
- end
193
-
194
- # Inside app/views/product/list.mab
195
- products.each do |product|
196
- p product.title
197
- end
198
- </pre>
199
- <h1>A Quick Tour</h1>
200
- <p>
201
- If you dive right into <a href="../classes/Markaby.html">Markaby</a>,
202
- it&#8217;ll probably make good sense, but you&#8217;re likely to run into a
203
- few kinks. Keep these pointers in mind and everything will be fine.
204
- </p>
205
- <h2>Element Classes</h2>
206
- <p>
207
- Element classes may be added by hooking methods onto container elements:
208
- </p>
209
- <pre>
210
- div.entry do
211
- h2.entryTitle 'Son of WebPage'
212
- div.entrySection %{by Anthony}
213
- div.entryContent 'Okay, once again, the idea here is ...'
214
- end
215
- </pre>
216
- <p>
217
- Which results in:
218
- </p>
219
- <pre>
220
- &lt;div class=&quot;entry&quot;&gt;
221
- &lt;h2 class=&quot;entryTitle&quot;&gt;Son of WebPage&lt;/h2&gt;
222
- &lt;div class=&quot;entrySection&quot;&gt;by Anthony&lt;/div&gt;
223
- &lt;div class=&quot;entryContent&quot;&gt;Okay, once again, the idea here is ...&lt;/div&gt;
224
- &lt;/div&gt;
225
- </pre>
226
- <h2>Element IDs</h2>
227
- <p>
228
- IDs may be added by the use of bang methods:
229
- </p>
230
- <pre>
231
- div.page!
232
- div.content!
233
- h1 &quot;A Short Short Saintly Dog&quot;
234
- end
235
- end
236
- </pre>
237
- <p>
238
- Which results in:
239
- </p>
240
- <pre>
241
- &lt;div id=&quot;page&quot;&gt;
242
- &lt;div id=&quot;content&quot;&gt;
243
- &lt;h1&gt;A Short Short Saintly Dog&lt;/h1&gt;
244
- &lt;/div&gt;
245
- &lt;/div&gt;
246
- </pre>
247
- <h2><a href="../classes/Markaby.html">Markaby</a> assumes XHTML 1.0 Transitional</h2>
248
- <p>
249
- Output defaults to XHTML 1.0 Transitional. To do XHTML 1.0 Strict, try
250
- this:
251
- </p>
252
- <pre>
253
- xhtml_strict do
254
- # innerds
255
- end
256
- </pre>
257
- <h2>The <tt>capture</tt> Method</h2>
258
- <p>
259
- Want to catch a block of HTML as a string and play with it a bit? Use the
260
- <tt>capture</tt> method.
261
- </p>
262
- <p>
263
- Commonly used to join HTML blocks together:
264
- </p>
265
- <pre>
266
- div.menu! \
267
- ['5.gets', 'bits', 'cult', 'inspect', '-h'].map do |category|
268
- capture { link_to category }
269
- end.
270
- join( &quot; | &quot; )
271
- </pre>
272
- <h2>The <tt>tag!</tt> Method</h2>
273
- <p>
274
- If you need to force a tag at any time, call <tt>tag!</tt> with the tag
275
- name followed by the possible arguments and block. The CssProxy won&#8217;t
276
- work with this technique.
277
- </p>
278
- <pre>
279
- tag! :select, :id =&gt; &quot;country_list&quot; do
280
- countries.each do |country|
281
- tag! :option, country
282
- end
283
- end
284
- </pre>
285
- <h1>Credits</h1>
286
- <p>
287
- <a href="../classes/Markaby.html">Markaby</a> is a work of immense hope by
288
- Tim Fletcher and why the lucky stiff. Thankyou for giving it a whirl.
289
- </p>
290
- <p>
291
- <a href="../classes/Markaby.html">Markaby</a> is inspired by the HTML
292
- library within cgi.rb. Hopefully it will turn around and take some cues.
293
- </p>
294
-
295
- </div>
296
-
297
-
298
- </div>
299
-
300
-
301
- </div>
302
-
303
-
304
- <!-- if includes -->
305
-
306
- <div id="section">
307
-
308
-
309
-
310
-
311
-
312
-
313
-
314
-
315
- <!-- if method_list -->
316
-
317
-
318
- </div>
319
-
320
-
321
- <div id="validator-badges">
322
- <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
323
- </div>
324
-
325
- </body>
326
- </html>