I am trying to create a select element using EJS (embedded javascript) in Geddy framework. What I want to do is have something like (just an example):
<select>
<option value="int"> Integer </option>
<option value="float"> Single precision decimal point </option>
</select>
I don't find any examples... I know that for creating a select like
<select>
<option value="X"> X </option>
<option value="Y"> Y </option>
</select>
I have to write
<%- contentTag('select', ['X', 'Y']} %>
But how to obtain what I want?
UPDATE:
I've found the select_tag in the EJS documentation, but it is not recognized... I've also tried a hybrid like
<%- contentTag('select', [{value: NumberTypeEL.NonNegativeInteger, text:'nonnegative integer'}, {value: NumberTypeEL.Integer, text: 'integer'}, {value: NumberTypeEL.Decimal, text: 'decimal'}, {value:NumberTypeEL.Fraction, text:'fraction'}], {class:'span6', name:'numberType'}) %>
but still nothing. Any other ideas?
On the new version there's a new selectTag. It works like the EJS example you referred to, so you can pass an array of objects. It also lets you specify a selectedOption. You can still use
contentTag("select"...)
and it works with the array of objects, however, with the contentTag you can't select an option.Another way to do this that was already there is to use contentTag and pass it a string instead of an array like
Please have a look at the documentation on geddyjs.org/documentation and look for
selectTag
NOTE: the documentation updates over night, so it might not be there when you go there, I'm copying it for now.
selectTag
`selectTagString(optionsArray, selectedOption, htmlOptions)
Creates a HTML select tag using the given
optionsArray
to create HTML option elements.
Examples:optionsArray
could be an array of strings, numbers or an object with value and text properties to be used for the value attribute and option element content respectively.