From: Graham Knop Date: Fri, 8 Mar 2019 02:07:50 +0000 (+0100) Subject: use double bracketed formatting codes so < and > don't need to be escaped X-Git-Tag: v5.9010~21 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Manual.git;a=commitdiff_plain;h=429d1caf111575afa4c25287cc48d7ed712af327 use double bracketed formatting codes so < and > don't need to be escaped --- diff --git a/lib/Catalyst/Manual/CatalystAndMoose.pod b/lib/Catalyst/Manual/CatalystAndMoose.pod index a228c16..9b01ac4 100644 --- a/lib/Catalyst/Manual/CatalystAndMoose.pod +++ b/lib/Catalyst/Manual/CatalystAndMoose.pod @@ -38,13 +38,13 @@ A Moose-ified version of the context class should look like this: $c->log->info( 'done!' ); } -You should also be aware that roles in C<< $c-Esetup >> are applied +You should also be aware that roles in C<< $c->setup >> are applied after the last plugin with all the benefits of using a single L statement in an ordinary L class. Your class is automatically made immutable at the end of the current file. -CAVEAT: Using roles in C<< $c-Esetup >> was implemented in Catalyst +CAVEAT: Using roles in C<< $c->setup >> was implemented in Catalyst version 5.80004. In prior versions you might get away with after 'setup_plugins' => sub{ with( @@ -58,14 +58,14 @@ version 5.80004. In prior versions you might get away with but this is discouraged and you should upgrade to 5.80004 anyway, because it fixes a few important regressions against 5.71 -CAVEAT: Using roles in C<< $c-Esetup >> will not currently allow +CAVEAT: Using roles in C<< $c->setup >> will not currently allow you to pass parameters to roles, or perform conflict resolution. Conflict detection still works as expected. =head2 ACCESSORS -Most of the request-specific attributes like C<$c-Estash>, -C<$c-Erequest> and C<$c-Eresponse> have been converted to +Most of the request-specific attributes like C<< $c->stash >>, +C<< $c->request >> and C<< $c->response >> have been converted to L attributes but without type constraints, attribute helpers or builder methods. This ensures that Catalyst 5.8 is fully backwards compatible to applications using the published API of Catalyst 5.7 but diff --git a/lib/Catalyst/Manual/Cookbook.pod b/lib/Catalyst/Manual/Cookbook.pod index f689e41..a550208 100644 --- a/lib/Catalyst/Manual/Cookbook.pod +++ b/lib/Catalyst/Manual/Cookbook.pod @@ -70,7 +70,7 @@ Normally you enable the debugging info by adding the C<-Debug> flag to your C statement . However, you can also enable it using environment variable, so you can (for example) get debug info without modifying your application scripts. Just set C or -CMYAPPE_DEBUG> to a true value. +C<< _DEBUG >> to a true value. =head2 Sessions @@ -1625,7 +1625,7 @@ static content to the view, perhaps like this: This code will only forward to the view if a template has been previously defined by a controller and if there is not already data in -C<$c-Eres-Ebody>. +C<< $c->res->body >>. Next, create a controller to handle requests for the /static path. Use the Helper to save time. This command will create a stub controller as diff --git a/lib/Catalyst/Manual/ExtendingCatalyst.pod b/lib/Catalyst/Manual/ExtendingCatalyst.pod index 97c31b6..73af1bd 100644 --- a/lib/Catalyst/Manual/ExtendingCatalyst.pod +++ b/lib/Catalyst/Manual/ExtendingCatalyst.pod @@ -243,7 +243,7 @@ class|/"Component base classes">. =head2 Component Configuration At creation time, the class configuration of your component (the one -available via C<$self-Econfig>) will be merged with possible +available via C<< $self->config >>) will be merged with possible configuration settings from the applications configuration (either directly or via config file). This is done by Catalyst, and the correctly merged configuration is passed to your component's diff --git a/lib/Catalyst/Manual/Intro.pod b/lib/Catalyst/Manual/Intro.pod index 7bff03f..87914f3 100644 --- a/lib/Catalyst/Manual/Intro.pod +++ b/lib/Catalyst/Manual/Intro.pod @@ -296,7 +296,7 @@ be C, and the second that it should be a Template Toolkit view.) This gives us a process() method and we can now just do $c->forward('MyApp::View::TT') to render our templates. The base class makes process() implicit, so we don't have to say -C<$c-Eforward(qw/MyApp::View::TT process/)>. +C<< $c->forward(qw/MyApp::View::TT process/) >>. sub hello : Global { my ( $self, $c ) = @_; @@ -315,7 +315,7 @@ In practice, however, you would use a default C action as supplied by L. Also, be sure to put the template under the directory specified in -C<$c-Econfig-E{root}>, or you'll end up looking at the debug +C<< $c->config->{root} >>, or you'll end up looking at the debug screen. =head4 Models @@ -402,7 +402,7 @@ gain several things: you don't have to C each component, Catalyst will find and load it automatically at compile-time; you can C to the module, which can only be done to Catalyst components. Only Catalyst components can be fetched with -C<$c-Emodel('SomeModel')>. +C<< $c->model('SomeModel') >>. Happily, since many people have existing Model classes that they would like to use with Catalyst (or, conversely, they want to @@ -623,7 +623,7 @@ Optionally, you can specify a B parameter for templates and static data. If omitted, Catalyst will try to auto-detect the directory's location. You can define as many parameters as you want for plugins or whatever you need. You can access them anywhere in your application via -C<$context-Econfig-E{$param_name}>. +C<< $context->config->{$param_name} >>. =head3 Context @@ -977,9 +977,9 @@ other paths. For both C<:LocalRegex> and C<:Regex> actions, if you use capturing parentheses to extract values within the matching URL, those values -are available in the C<$c-Ereq-Ecaptures> array. In the above +are available in the C<< $c->req->captures >> array. In the above example, "widget23" would capture "23" in the above example, and -C<$c-Ereq-Ecaptures-E[0]> would be "23". If you want to +C<< $c->req->captures->[0] >> would be "23". If you want to pass arguments at the end of your URL, you must use regex action keys. See L below. @@ -1030,7 +1030,7 @@ forwarding from another component, you must use the absolute path to the method, so that a private C method in your C controller must, if called from elsewhere, be reached with -C<$c-Eforward('/catalog/order/process/bar')>. +C<< $c->forward('/catalog/order/process/bar') >>. =back @@ -1263,13 +1263,13 @@ debugging enabled). } A C does not create a new request, so your request object -(C<$c-Ereq>) will remain unchanged. This is a key difference between +(C<< $c->req >>) will remain unchanged. This is a key difference between using C and issuing a redirect. You can pass new arguments to a C by adding them -in an anonymous array. In this case C<$c-Ereq-Eargs> +in an anonymous array. In this case C<< $c->req->args >> will be changed for the duration of the C only; upon -return, the original value of C<$c-Ereq-Eargs> will +return, the original value of C<< $c->req->args >> will be reset. sub hello : Global { diff --git a/lib/Catalyst/Manual/Tutorial/02_CatalystBasics.pod b/lib/Catalyst/Manual/Tutorial/02_CatalystBasics.pod index c4524ec..99b531b 100644 --- a/lib/Catalyst/Manual/Tutorial/02_CatalystBasics.pod +++ b/lib/Catalyst/Manual/Tutorial/02_CatalystBasics.pod @@ -285,9 +285,9 @@ context provides access to "response" and "request" objects. (See L, L, and L) -C<$c-Eresponse-Ebody> sets the HTTP response (see +C<< $c->response->body >> sets the HTTP response (see L), while -C<$c-Ewelcome_message> is a special method that returns the welcome +C<< $c->welcome_message >> is a special method that returns the welcome message that you saw in your browser. The ":Path :Args(0)" after the method name are attributes which @@ -424,13 +424,13 @@ following: $c->stash(template => 'hello.tt'); } -This time, instead of doing C<$c-Eresponse-Ebody()>, you are +This time, instead of doing C<< $c->response->body() >>, you are setting the value of the "template" hash key in the Catalyst "stash", an area for putting information to share with other parts of your application. The "template" key determines which template will be displayed at the end of the request cycle. Catalyst controllers have a default "end" action for all methods which causes the first (or default) -view to be rendered (unless there's a C<$c-Eresponse-Ebody()> +view to be rendered (unless there's a C<< $c->response->body() >> statement). So your template will be magically displayed at the end of your method. @@ -462,7 +462,7 @@ You can also set multiple stash values with a hashref: $c->stash({template => 'hello.tt', foo => 'bar', another_thing => 1}); -Any of these formats work, but the C<$c-Estash(name =E value);> +Any of these formats work, but the C<< $c->stash(name => value); >> style is growing in popularity -- you may wish to use it all the time (even when you are only setting a single value). diff --git a/lib/Catalyst/Manual/Tutorial/03_MoreCatalystBasics.pod b/lib/Catalyst/Manual/Tutorial/03_MoreCatalystBasics.pod index 9bf0ce3..be9b2ec 100644 --- a/lib/Catalyst/Manual/Tutorial/03_MoreCatalystBasics.pod +++ b/lib/Catalyst/Manual/Tutorial/03_MoreCatalystBasics.pod @@ -143,7 +143,7 @@ If you prefer, there are several other ways to enable debug output: =item * -the C<$c-Edebug> method on the C<$c> Catalyst context object +the C<< $c->debug >> method on the C<$c> Catalyst context object =item * @@ -498,7 +498,7 @@ This changes the default extension for Template Toolkit from '.tt' to You can also configure components in your application class. For example, Edit C and you should see the default -configuration above the call to C<_PACKAGE__-Esetup> (your defaults +configuration above the call to C<< _PACKAGE__->setup >> (your defaults could be different depending on the version of Catalyst you are using): __PACKAGE__->config( @@ -509,7 +509,7 @@ could be different depending on the version of Catalyst you are using): Change this to match the following (insert a new -C<__PACKAGE__-Econfig> below the existing statement): +C<< __PACKAGE__->config >> below the existing statement): __PACKAGE__->config( name => 'MyApp', @@ -677,7 +677,7 @@ Then use the following command to build a C SQLite database: If you need to create the database more than once, you probably want to issue the C command to delete the database before you use -the C myapp01.sql> command. +the C<< sqlite3 myapp.db < myapp01.sql >> command. Once the C database file has been created and initialized, you can use the SQLite command line environment to do a quick dump of the @@ -882,7 +882,7 @@ L version C<0.05000> or later. Open C and un-comment the model code we left disabled earlier so that your version matches the following -(un-comment the line containing C<[$c-Emodel('DB::Book')-Eall]> +(un-comment the line containing C<< [$c->model('DB::Book')->all] >> and delete the next 2 lines): =head2 list @@ -907,14 +907,14 @@ and delete the next 2 lines): $c->stash(template => 'books/list.tt2'); } -B: You may see the C<$c-Emodel('DB::Book')> un-commented above -written as C<$c-Emodel('DB')-Eresultset('Book')>. The two are -equivalent. Either way, C<$c-Emodel> returns a +B: You may see the C<< $c->model('DB::Book') >> un-commented above +written as C<< $c->model('DB')->resultset('Book') >>. The two are +equivalent. Either way, C<< $c->model >> returns a L which handles queries against the database and iterating over the set of results that is returned. -We are using the C<-Eall> to fetch all of the books. DBIC supports +We are using the C<< ->all >> to fetch all of the books. DBIC supports a wide variety of more advanced operations to easily do things like filtering and sorting the results. For example, the following could be used to sort the results by descending title: @@ -943,7 +943,7 @@ you are using a different shell (for example, under tcsh, use C). B You can also set this in your code using -C<$class-Estorage-Edebug(1);>. See +C<< $class->storage->debug(1); >>. See L for details (including options to log to a file instead of displaying to the Catalyst development server log). @@ -1132,7 +1132,7 @@ Notice the status and error message sections in the code above: [% error_msg %] If we set either message in the Catalyst stash (e.g., -C<$c-Estash-E{status_msg} = 'Request was successful!'>) it will +C<< $c->stash->{status_msg} = 'Request was successful!' >>) it will be displayed whenever any view used by that request is rendered. The C and C CSS styles can be customized to suit your needs in the C file we create below. @@ -1349,12 +1349,12 @@ C<1;> on a line by itself. The C relationship bridge is optional, but it makes it easier to map a book to its collection of authors. Without it, we would have to "walk" through the C table as in -C<$book-Ebook_author-Efirst-Eauthor-Elast_name> (we will +C<< $book->book_author->first->author->last_name >> (we will see examples on how to use DBIx::Class objects in your code soon, but -note that because C<$book-Ebook_author> can return multiple authors, +note that because C<< $book->book_author >> can return multiple authors, we have to use C to display a single author). C allows us to use the shorter -C<$book-Eauthor-Efirst-Elast_name>. Note that you cannot +C<< $book->author->first->last_name >>. Note that you cannot define a C relationship bridge without also having the C relationship in place. @@ -1454,7 +1454,7 @@ DBIx::Class): JOIN author author ON author.id = me.author_id WHERE ( me.book_id = ? ): '5' Also note in C that we are using "| html", a -type of TT filter, to escape characters such as E and E to < +type of TT filter, to escape characters such as < and > to < and > and avoid various types of dangerous hacks against your application. In a real application, you would probably want to put "| html" at the end of every field where a user has control over the @@ -1587,11 +1587,11 @@ By default, C will look for a template that uses the same name as your controller action, allowing you to save the step of manually specifying the template name in each action. For example, this would allow us to remove the -C<$c-Estash-E{template} = 'books/list.tt2';> +C<< $c->stash->{template} = 'books/list.tt2'; >> line of our C action in the Books controller. Open C in your editor and comment out this line to match the following (only the -C<$c-Estash-E{template}> line has changed): +C<< $c->stash->{template} >> line has changed): =head2 list @@ -1620,8 +1620,8 @@ You should now be able to access the L URL as before. B If you use the default template technique, you -will B be able to use either the C<$c-Eforward> or the -C<$c-Edetach> mechanisms (these are discussed in Chapter 2 and +will B be able to use either the C<< $c->forward >> or the +C<< $c->detach >> mechanisms (these are discussed in Chapter 2 and Chapter 9 of the Tutorial). B Make sure that you do B skip the following section @@ -1630,7 +1630,7 @@ before continuing to the next chapter 4 Basic CRUD. =head2 Return To A Manually Specified Template -In order to be able to use C<$c-Eforward> and C<$c-Edetach> +In order to be able to use C<< $c->forward >> and C<< $c->detach >> later in the tutorial, you should remove the comment from the statement in C in C: diff --git a/lib/Catalyst/Manual/Tutorial/04_BasicCRUD.pod b/lib/Catalyst/Manual/Tutorial/04_BasicCRUD.pod index 0df6ab2..3addacb 100644 --- a/lib/Catalyst/Manual/Tutorial/04_BasicCRUD.pod +++ b/lib/Catalyst/Manual/Tutorial/04_BasicCRUD.pod @@ -416,11 +416,11 @@ method: } Here we print a log message and store the DBIC ResultSet in -C<$c-Estash-E{resultset}> so that it's automatically available +C<< $c->stash->{resultset} >> so that it's automatically available for other actions that chain off C. If your controller always needs a book ID as its first argument, you could have the base method capture that argument (with C<:CaptureArgs(1)>) and use it to pull the -book object with C<-Efind($id)> and leave it in the stash for later +book object with C<< ->find($id) >> and leave it in the stash for later parts of your chains to then act upon. Because we have several actions that don't need to retrieve a book (such as the C we are working with now), we will instead add that functionality to a common @@ -645,7 +645,7 @@ that modifies data should be handled with a form sending a POST request). Also notice that we are using a more advanced form of C than we -have seen before. Here we use C<$c-Econtroller-Eaction_for> to +have seen before. Here we use C<< $c->controller->action_for >> to automatically generate a URI appropriate for that action based on the method we want to link to while inserting the C value into the appropriate place. Now, if you ever change C<:PathPart('delete')> in @@ -660,13 +660,13 @@ few shortcuts and options when using C: =item * If you are referring to a method in the current controller, you can use -C<$self-Eaction_for('_method_name_')>. +C<< $self->action_for('_method_name_') >>. =item * If you are referring to a method in a different controller, you need to include that controller's name as an argument to C, as in -C<$c-Econtroller('_controller_name_')-Eaction_for('_method_name_')>. +C<< $c->controller('_controller_name_')->action_for('_method_name_') >>. =back @@ -716,7 +716,7 @@ add the following code: } Now, any other method that chains off C will automatically have -the appropriate book waiting for it in C<$c-Estash-E{object}>. +the appropriate book waiting for it in C<< $c->stash->{object} >>. =head2 Add a Delete Action to the Controller @@ -807,7 +807,7 @@ application or database), but in other cases this could clearly lead to trouble. We can improve the logic by converting to a redirect. Unlike -C<$c-Eforward('list'))> or C<$c-Edetach('list'))> that perform a +C<< $c->forward('list')) >> or C<< $c->detach('list')) >> that perform a server-side alteration in the flow of processing, a redirect is a client-side mechanism that causes the browser to issue an entirely new request. As a result, the URL in the browser is updated to match the @@ -899,7 +899,7 @@ query parameter: Although the sample above only shows the C div, leave the rest of the file intact -- the only change we made to the C was to add "C<|| c.request.params.status_msg>" to the -Cspan class="message"E> line. Note that we definitely want +C<< >> line. Note that we definitely want the "C<| html>" TT filter here since it would be easy for users to modify the message on the URL and possibly inject harmful code into the application if we left that off. @@ -1200,7 +1200,7 @@ and add the following method: We defined the search string as C<$title_str> to make the method more flexible. Now update the C method in C to match the following (we have -replaced the C<-Esearch> line with the C<-Etitle_like> line +replaced the C<< ->search >> line with the C<< ->title_like >> line shown here -- the rest of the method should be the same): =head2 list_recent_tcp diff --git a/lib/Catalyst/Manual/Tutorial/05_Authentication.pod b/lib/Catalyst/Manual/Tutorial/05_Authentication.pod index adf66fc..75c1482 100644 --- a/lib/Catalyst/Manual/Tutorial/05_Authentication.pod +++ b/lib/Catalyst/Manual/Tutorial/05_Authentication.pod @@ -281,7 +281,7 @@ sets a reasonable set of defaults for us. (Note: the C here has nothing to do with the SimpleDB offered in Amazon's web services offerings -- here we are only talking about a "simple" way to use your DB as an authentication backend.) Open C and place the -following text above the call to C<__PACKAGE__-Esetup();>: +following text above the call to C<< __PACKAGE__->setup(); >>: # Configure SimpleDB Authentication __PACKAGE__->config( @@ -807,7 +807,7 @@ flash vs. the C query parameter: Although the sample above only shows the C div, leave the rest of the file intact -- the only change we made to replace "|| c.request.params.status_msg" with "c.flash.status_msg" in the -Cspan class="message"E> line. +C<< >> line. =head2 Try Out Flash diff --git a/lib/Catalyst/Manual/Tutorial/07_Debugging.pod b/lib/Catalyst/Manual/Tutorial/07_Debugging.pod index bb9a558..faca57f 100644 --- a/lib/Catalyst/Manual/Tutorial/07_Debugging.pod +++ b/lib/Catalyst/Manual/Tutorial/07_Debugging.pod @@ -85,7 +85,7 @@ Catalyst is able to easily accommodate both styles of debugging. =head1 LOG STATEMENTS -Folks in the former group can use Catalyst's C<$c-Elog> facility. +Folks in the former group can use Catalyst's C<< $c->log >> facility. (See L for more detail.) For example, if you add the following code to a controller action method: diff --git a/lib/Catalyst/Manual/Tutorial/08_Testing.pod b/lib/Catalyst/Manual/Tutorial/08_Testing.pod index bf759d8..b28fc08 100644 --- a/lib/Catalyst/Manual/Tutorial/08_Testing.pod +++ b/lib/Catalyst/Manual/Tutorial/08_Testing.pod @@ -358,7 +358,7 @@ databases. One solution is to allow the database specification to be overridden with an environment variable. For example, open C in your editor and change the -C<__PACKAGE__-Econfig(...> declaration to resemble: +C<< __PACKAGE__->config(... >> declaration to resemble: my $dsn = $ENV{MYAPP_DSN} ||= 'dbi:SQLite:myapp.db'; __PACKAGE__->config( diff --git a/lib/Catalyst/Manual/Tutorial/09_AdvancedCRUD/09_FormFu.pod b/lib/Catalyst/Manual/Tutorial/09_AdvancedCRUD/09_FormFu.pod index 0dcc0af..c3fd466 100644 --- a/lib/Catalyst/Manual/Tutorial/09_AdvancedCRUD/09_FormFu.pod +++ b/lib/Catalyst/Manual/Tutorial/09_AdvancedCRUD/09_FormFu.pod @@ -510,21 +510,21 @@ error message and return to the book list. =item * If the form has been submitted and passes validation, we skip creating a -new book and just use C<$form-Emodel-Eupdate> to update the +new book and just use C<< $form->model->update >> to update the existing book. =item * If the form is being displayed for the first time (or has failed validation and it being redisplayed), we use -C<$form-Emodel-Edefault_values> to populate the form with data +C<< $form->model->default_values >> to populate the form with data from the database. =back Then, edit C and add a new link below the existing "Delete" link that allows us to edit/update each existing book. -The last EtdE cell in the book list table should look like the +The last cell in the book list table should look like the following: ... diff --git a/lib/Catalyst/Manual/Tutorial/10_Appendices.pod b/lib/Catalyst/Manual/Tutorial/10_Appendices.pod index 8c4b513..0d0b3ae 100644 --- a/lib/Catalyst/Manual/Tutorial/10_Appendices.pod +++ b/lib/Catalyst/Manual/Tutorial/10_Appendices.pod @@ -123,7 +123,7 @@ entered on the last line. You can limit the replacement operation by selecting text first (depending on your version of Emacs, you can either use the mouse or experiment with commands such as C to set the mark at the cursor location and -C> and C> to set the mark at the beginning and end of the +C<< C-< >> and C<< C-> >> to set the mark at the beginning and end of the file respectively. Also, Stefan Kangas sent in the following tip about an alternate @@ -200,7 +200,7 @@ And then restart PostgreSQL: =item * Create the database and a user for the database (note that we are -using "EcatalystE" to represent the hidden password of +using "" to represent the hidden password of "catalyst"): $ sudo -u postgres createuser -P catappuser