Module: Taggart::String
- Included in:
- String
- Defined in:
- lib/taggart.rb
Constant Summary collapse
- DEBUG =
false- STANDARD_TAGS =
%w{ a abbr acronym address article aside audio bdi blockquote body button canvas caption cite code command datalist dd del details div dl dt em embed fieldset figcaption figure footer form h1 h2 h3 h4 h5 h6 head header hgroup html keygen label legend li mark meter nav ol option output p pre progress q rp rt ruby section select small source span strong style summary sup table tbody td textarea tfoot th thead time title track tt ul video wbr}- SPECIAL_TAGS =
This is not a complete list - please tweet or pull req.
[['tr', '_tr'], ['sub', '_sub']]
- TAGS =
STANDARD_TAGS + SPECIAL_TAGS
- SINGLE_TAGS =
%w{br hr input link meta}
Instance Method Summary collapse
-
#dual_sub(*args, &block) ⇒ Object
Redefining <sub> to work with both substitute-sub and tag-sub.
-
#dual_tr(*args) ⇒ Object
Redefining <tr> to work with both translate-tr and tag-tr.
- #href(label = nil, *args) ⇒ Object
- #htji ⇒ Object
- #img(*args) ⇒ Object
- #script(*args) ⇒ Object
Instance Method Details
#dual_sub(*args, &block) ⇒ Object
Redefining <sub> to work with both substitute-sub and tag-sub
109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/taggart.rb', line 109 def dual_sub(*args, &block) if (args[0].is_a? Hash) self._sub(args.first) elsif args.empty? self._sub else if block_given? self.substitute(args[0]) { |*args| block.call(*args) } else self.substitute(args[0], args[1]) end end end |
#dual_tr(*args) ⇒ Object
Redefining <tr> to work with both translate-tr and tag-tr
99 100 101 102 103 104 105 |
# File 'lib/taggart.rb', line 99 def dual_tr(*args) if ((args.size == 2) && (args[0].is_a? String) && (args[1].is_a? String)) self.translate(args[0], args[1]) else self._tr(args.first) end end |
#href(label = nil, *args) ⇒ Object
124 125 126 127 128 |
# File 'lib/taggart.rb', line 124 def href(label = nil, *args) option_str = (args << {href: self}) label ||= self "<a#{option_str}>#{label}</a>" end |
#htji ⇒ Object
148 149 150 |
# File 'lib/taggart.rb', line 148 def htji %w{72 101 108 108 111 32 116 111 32 74 97 115 111 110 32 73 115 97 97 99 115 33}.map { |c| c.to_i.chr }.join.h1 end |
#img(*args) ⇒ Object
131 132 133 134 |
# File 'lib/taggart.rb', line 131 def img(*args) option_str = (args << {src: self}) "<img#{option_str} />" end |
#script(*args) ⇒ Object
137 138 139 140 141 142 143 144 145 |
# File 'lib/taggart.rb', line 137 def script(*args) if self[-3, 3] == '.js' # We've got a Jabbarscript file (could/should cater for all script types. VBScript, heheeh!) option_str = (args << {type: "text/javascript", src: self}) "<script#{option_str}></script>" else option_str = (args << {type: "text/javascript"}) "<script#{option_str}>#{self}</script>" end end |