Support for changing default navigate and submit template elements, such as adding classes for styling
Support for changing default navigate and submit template elements, such as adding classes for styling.
This avoids having to make more heavyweight template overrides or renamed versions such as
Submitted by Danny Groenewegen on 18 November 2013 at 15:27horizontalForm
instead ofform
.
Issue Log
and for input, e.g. to add class
form-control
design outline:
define named sets of attributes
attributes navigate { class = "btn btn-default" style = "display:inline;" } attributes form { role = "form" } attributes input{ class = "form-control" }
These will be added to built-in.app standard library. Template elements that are still in the generator, like navigate, submit, submitlink, and form, will have the retrieved attribute set name hardcoded for now. Templates that are already library defined will be able to retrieve the elements as follows:
template input(i : Ref<Int>){ inputInternal[ .... all attributes input attributes ]{....} .... } template inputInternal(i : Ref<Int>){ <input .... all attributes /> .... }
or directly inserted into the HTML tag:
template input(i : Ref<Int>){ <input .... all attributes input attributes /> .... }
The
all attributes
will take precedence as these are the explicit attributes on a particular template call.A styling library, e.g. one that wraps bootstrap, can override the attribute sets (similar to template overrides):
override attributes input{ class = "form-control" }
This only allows one override but covers the current use case of a single coherent styling library. If there is a need for multiple application areas with different default attributes, we could add support for a dynamic local override also similar to templates.
An alternative design we discussed is to match template signatures for applying specific attributes, an aspect oriented style similar to ac rules. However, explicit references to a named attribute set that can be checked to exist and resolved to in the IDE fits better with the general WebDSL design.
implemented
Log in to post comments