I did upgrade from Tapestry's default template to Bootstrap 1 then 2 and it
caused me to rethink the whole way I was doing things. 

When I built the Bootstrap 2 module I created one mixin called framework and
used a worker to add it to all components. Then I created a service to
handle the framework specific markup. This way the framework is pluggable.
If you don't like Bootstrap create your own framework service and override
the Bootstrap one. The service is also extensible so it's possible to add
your own markup for your own components.

The framework mixin takes one argument that tells it how to render. The
mixin then puts the render type into the environment so subcomponents can
see it. So for a form the render parameter would be "horizontal". The input
components can get that from the environment and do the right thing. If for
some reason you don't want a particular textfield to output control divs and
labels it's possible to specify how it renders. For example


<t:form render="horizontal">
<t:textfield t:id=name/>
<t:textfield t:id=email render="none"/>
<t:submit />
</t:form>

If you are using Bootstrap this will render a horizontal form with a control
group and label around the name field. The email field will not have any
additional markup. There is no Bootstrap markup in the template. Hopefully
Bootstrap 3 will have some type of horizontal form and the service can just
make it work.

For me the last thing I want in the template it extra markup to make things
pretty. I'll do that with a service and CSS. This way I can change one place
and the whole site changes, but it's also flexible enough to work will all
the markup in the tml file because

<t:form >
</t:form>

Has no render type so all the subcomponents will just render without the
extra markup needed for a horizontal form.



--
View this message in context: 
http://tapestry.1045711.n5.nabble.com/Idea-for-5-4-ControlGroup-mixin-tp5718691p5718732.html
Sent from the Tapestry - Dev mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to