Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
As rhesa mentioned, you don't do output directly from your view. Rather you give the output generated by your view back to the Catalyst. (In this way, Catalyst is like CGI::Appl and several other MVC frameworks)

While this interface seems cumbersome and adds a little overhead, it does allow for some nice capabilities, like centralized error processing, wrappers, or post-processing (think XSL transformations). I'm sure other people have really good examples of capabilities.

Anyway, you want to be looking in the documentation for how to use $c->response->body (the shorthand reference you'll often see is $c->res->body . If you look into other view code sources, you will that view actions can end with code like:

$c->response->body($output); return 1;
where previously generated output in $output is given to Catalyst and the view routine simply returns. You replace or add to the output body contents using the API. When you return from the view component, Catalyst (or other components in your application) may examine or modify the contents of the body. Then Catalyst will output the header, then the body.

You will also want to check out things like $c->response->status and $c->response->content_type to see how to interact with Catalyst to specify the other HTTP output data.


In reply to Re: creating a Catalyst View component by shenme
in thread creating a Catalyst View component by holli

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (None)
    As of 2024-04-19 00:02 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found