Skip to content

Instantly share code, notes, and snippets.

@julienrf
Created September 26, 2011 12:57
Show Gist options
  • Save julienrf/1242177 to your computer and use it in GitHub Desktop.
Save julienrf/1242177 to your computer and use it in GitHub Desktop.
*{ Liste éditable d’éléments }*
*{ @param _arg: Iterable[A] Liste des éléments constitutifs de la liste }*
*{ @param as: String Name of the iterator }*
*{ @param (optional) addAction: ActionDefinition URL permettant d’ajouter un élément }*
*{ @param (optional) pager: Pager }*
#{ui.list users, as: 'user', addAction: @Users.add(), pager: pager}
#{useritem user /}
#{/ui.list}
*{ Formulaire }*
*{ @param _arg: ActionDefinition }*
*{ @param (optional) model: Model to use (will prefix each field name with the model name and add validation annotations inside fields) }*
#{ui.form @User.create(), model: user}
#{ui.field 'name' /}
#{ui.field 'password', type: 'password' /}
#{ui.field 'hasFoo', type: 'checkbox' /}
#{customfield 'bar' /}
#{ui.field 'avatar', type: 'file' /}
#{ui.formbuttons}
#{ui.button 'user-create', type: 'submit' /}
#{/ui.formbuttons}
#{/ui.form}
%{
form = new utils.ui.FormBuilder(@Users.create(), user) {{
field('name')
field('password', 'password')
field('hasFoo', 'checkbox')
customField('bar', 'modules/users/customfield.html')
field()
button('user-create', 'submit')
}}
}%
${form.make()}
%{ user = _arg }%
#{extends 'listitem.html' /}
<div class="user">
<span class="name">${user.name}</span>
</div>
#{set 'delete'}
<button type="button" class="delete" data-id="${user.id}">&{'delete'}</button>
#{/set}
#{set 'edit'}
<a href="@Users.edit(user.id)" class="button edit">&{'edit'}</a>
#{/set}
*{ Base template to write list items }*
*{ Build a list item by appending an item content, an edit button and then a delete button }*
<li class="list-item">
<span class="content">
#{doLayout /}
</span>
#{if get('edit') || get('delete')}
<span class="aside">
#{if get('edit')}
#{get 'edit' /}
#{/if}
#{if get('delete')}
#{get 'delete' /}
#{/if}
</span>
#{/if}
</li>
*{ Custom field keeping consistency with sematic built-in fields }*
*{ @params _arg: String Name of the field }*
#{extends 'ui.fieldbase.html' /}
%{ field = utils.GroovyFieldHelper.field(_arg) }%
#{ui.fieldbase _arg }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment