RHTMLO, markup and typesetting

7 views
Skip to first unread message

Gordon Haverland

unread,
Aug 1, 2011, 5:59:12 PM8/1/11
to rose-htm...@googlegroups.com
I'm still trying to get some level of comfort with respect to the
Rose:: namespace and things related to HTML generation.

As near as I can tell, Rose::HTML::Form (and probably
Rose::HTMLx::Form) is meant to be adjusted in its presentation
solely by CSS and/or Javascript. It is not possible to mark this
up semantically in HTML (or XHTML)?

As I feel semantic markup for what I am doing it worth the effort,
I am using Rose::HTML::Form::Field for things, and then using the
->html output to insert into strings or directly into Mojolicious
(epl) forms. It's entirely possible I am missing something, user
interfaces are not something I am good at (differential equations
are much easier). Am I correctly interpretting what the
Rose::HTML namespace provides?

Thanks.
Gord

John Siracusa

unread,
Aug 2, 2011, 4:12:37 PM8/2/11
to rose-htm...@googlegroups.com
On Mon, Aug 1, 2011 at 5:59 PM, Gordon Haverland
<ghav...@materialisations.com> wrote:
> As near as I can tell, Rose::HTML::Form (and probably
> Rose::HTMLx::Form) is meant to be adjusted in its presentation
> solely by CSS and/or Javascript.  It is not possible to mark this
> up semantically in HTML (or XHTML)?

Each Rose::HTML::Object-derived object can return its own markup by
calling one of the html/xhtml methods. Methods are available for
parts of the object's markup (e.g., the label, the error, the field
itself) or for the whole field, label and all. Example method names:
html(), html_field(), html_label(), html_error(), etc. To change the
markup, you can subclass the field and override one or more of these
methods. Making a "private library" may help you do this by providing
subclasses for any new/overridden methods:

http://search.cpan.org/dist/Rose-HTML-Objects/lib/Rose/HTML/Objects.pm#PRIVATE_LIBRARIES

> As I feel semantic markup for what I am doing it worth the effort,
> I am using Rose::HTML::Form::Field for things, and then using the
> ->html output to insert into strings or directly into Mojolicious
> (epl) forms.

You're not really expected to call html() on a Rose::HTML::Form
object, since how a form is arranged varies so widely. Instead,
you're expected to call $form->start_html, then call
$form->field('foo')->html() (or html_label(), html_field(),
html_error(), etc.) and so on for each field, inserting them into your
template where you want them to go.

-John

Adam Prime

unread,
Aug 19, 2011, 11:48:56 AM8/19/11
to rose-htm...@googlegroups.com
On 11-08-02 04:12 PM, John Siracusa wrote:
> You're not really expected to call html() on a Rose::HTML::Form
> object, since how a form is arranged varies so widely. Instead,
> you're expected to call $form->start_html, then call
> $form->field('foo')->html() (or html_label(), html_field(),
> html_error(), etc.) and so on for each field, inserting them into your
> template where you want them to go.

Also, if you do have a very consistent way that you want forms rendered,
you can certainly add a method to your Rose::HTML::Form subclass to
render the form in that specific way. Another approach is to stash the
form rending logic in a TT BLOCK, whatever your templating engine of
choices version of BLOCK is.

Adam

Reply all
Reply to author
Forward
0 new messages