jkoudys / concrete5-xhp

XHP elements, so you can use Facebook's excellent XHP library to easily, and cleanly, include concrete5 data
6 stars 0 forks source link

Implement helper logic, rather than just wrapping it #1

Closed jkoudys closed 10 years ago

jkoudys commented 10 years ago

I'm sort of torn on this decision, since I can see advantages to either side. So long as c5 helpers, like the form helper, are being maintained, it makes sense to use them in the interest of DRYness. On the other side, I wan to reduce the usage of that c5:raw element down to a minimum, and that won't happen as long as I'm just dumping out raw HTML from everything.

As the form helper is rendering actual HTML elements, that logic could be re-implemented inside the render() code for the :c5 elements themselves. This could be extra handy if traversing your xhp dom later on, since form elements are one of the main things you'd want to search inside your tree for.

jkoudys commented 10 years ago

Commit 52c3991 pushed. This adds several new features to the form helper:

<c5:form>
  <c5:form-select name="favouriteFruit[]" options={ Map { 'p' => 'Pears', 'a' => 'Apples', 'o' => 'Oranges' } } selected="a" />
  <c5:form-select name="favouriteFruit[]" options={ Map { 'c' => 'Cantaloupe', 'p' => 'Pineapple', 's' => 'Strawberry' } } selected="s" />
</c5:form>

and it will now render their IDs as favouriteFruit1, favouriteFruit2. This is necessary as it's what the c5 backend expects.