amrita and checkboxes

M

Michael campbell

How does one control whether or not a checkbox is "checked" using amrita? I'm familiar with using the a:)attr => value) form for modifying an attribute WITHIN a tag, but this attribute is either present or absent, it doesn't have a value as such.

If I leave out the symbol, the entire tag is eliminated, not just the attribute within it.

Below, the "1" form is printed with "checked=on" as expected; the "2" form prints nothing; the entire text from <form> to </form> is eliminated, when all I want is the "checked" attribute WITHIN the <form..> tag to go away, not the whole thing.


Thoughts welcome.

require 'amrita/template'
include Amrita

t = TemplateText.new <<-html
<form method=post action=DYNAMIC_CONTENT_NEEDS_TO_BE_PLACED_HERE checked id=form>
<input type=text name=foobar>
</form>
html

data = {
:form => a:)action => 'myform.cgi', :checked => "on")
}

puts "1"
t.expand(STDOUT, data)

puts "2"
data = {
:form => a:)action => 'myform.cgi')
}
 
M

Michael campbell

Michael said:
How does one control whether or not a checkbox is "checked" using
amrita?

I'm an idiot, apologies for the earlier message. I had failed in my test script to do the second t.expand() call...

Apologies again to all.

This works as expected:

###
require 'amrita/template'
include Amrita

t = TemplateText.new <<-html
<input id=form type="checkbox" name="search" checked>
html

data = {
:form => a:)checked => "ON")
}

puts "1"
t.expand(STDOUT, data) # prints <input type="checkbox" name="search" checked="ON" action="myform.cgi">

puts "2"
data = {
:form => a:)checked=>nil)
}
t.expand(STDOUT, data)

# prints <input type="checkbox" name="search" action="myform.cgi">
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,586
Members
45,088
Latest member
JeremyMedl

Latest Threads

Top