Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


Add a View Helper to Generate a Select Tag #227

MiguelMadero opened this Issue · 4 comments

2 participants



<%- contentTag('select', todo.status, ['open', 'close'], { class:'span6', name:'status' }) %>
<%- contentTag('select', user.state, states, { class:'span6', name:'state' , prompt:'select a state...'}) %>
<%- contentTag('select', user.preferences, preferences, { class:'span6', name:'preferences' , multiple:true}) %>

@MiguelMadero MiguelMadero was assigned

Here's the original commit you made for context MiguelMadero/geddy@30d9506

@larzconwell larzconwell closed this issue from a commit
@larzconwell larzconwell Closes #227, added select tag support for contentTag, if the tag is s…
…elect and the content is an Array then it will use the array items as options for the select statement.

Also fixed some error dealing with i18n, where `lib/model/*` was requiring a non existant file/dir.

Okay I added select tag support. I used an Array as the content and then it creates a option tag for each item and included a value attribute on the tag.


contentTag('select', ['item', 'here'])
=> '<select><option value="item">item</option><option value="here">here</option></select>'

Edit: Oh wow I didn't even notice you assigned this to yourself, I'm sorry!! I didn't mean to take this from you man.


Don't worry. I'll reopen it and do a few changes. I would like to set the selected value based on the model. Let's say we're editing a TODO, the current status should be preselected:

<%- contentTag('select', todo.status, ['open', 'close'], { class:'span6', name:'status' }) %>

I'll also add support for multiple selection

@MiguelMadero MiguelMadero reopened this

Ah okay, cool. Don't forget to edit the docs, and tests (:

@MiguelMadero MiguelMadero was assigned
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.