attribute: selected_if, checked_if, selected_unless, checked_unless
<option value="1" selected_if="@cond">opt1</option>
becomes
<?r if @cond ?>
<option value="1" selected="selected">opt1</option>
<?r else ?>
<option value="1">opt1</option>
<?r end ?>
Methods
Public Class methods
[ show source ]
# File lib/raw/compiler/filter/morph/selected_if.rb, line 18
18: def self.key
19: "selected_if"
20: end
Public Instance methods
[ show source ]
# File lib/raw/compiler/filter/morph/selected_if.rb, line 29
29: def after_start(buffer)
30: @start_index = buffer.length
31: end
[ show source ]
# File lib/raw/compiler/filter/morph/selected_if.rb, line 33
33: def before_end(buffer)
34: @attributes.delete(@attr)
35: @end_index = buffer.length
36: buffer << Morphing.emit_end(@name)
37: buffer << "<?r else ?>"
38: buffer << Morphing.emit_start(@name, @attributes)
39: buffer << buffer[@start_index...@end_index]
40: end
[ show source ]
# File lib/raw/compiler/filter/morph/selected_if.rb, line 22
22: def before_start(buffer)
23: @attr, @cond = @key.split("_")
24: @attributes.delete(@key)
25: @attributes[@attr] = @attr
26: buffer << "<?r #@cond #@value ?> "
27: end