Located in File: /AkActionView/helpers/capture_helper.php
== Capturing a block into an instance variable
<?php $capture_helper->begin (); ?> [some html...] <?php $script = $capture_helper->end (); ?>
== Add javascript to header using content_for
$capture_helper->content_for("name"); is a wrapper for capture which will store the fragment in a instance variable similar to $content_for_layout.
layout.tpl:
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>layout with js</title> <script type="text/javascript"> {content_for_script} </script> </head> <body> {content_for_layout} </body> </html>
view.tpl
This page shows an alert box!
<?php $capture_helper->begin ('script'); ?> alert('hello world'); <?php $capture_helper->end (); ?>
Normal view text
Method begin (line 74)
Example:
<?php $capture_helper->begin(); ?> Welcome To my shiny new web page! <% $greeting = $capture_helper->end(); ?>
Method content_for (line 115)
The name of the instance variable is content_for_<name> to stay consistent with $content_for_layout which is used by ActionView's layouts
Example:
<?php $capture_helper->content_for('header'); ?> alert('hello world'); <?php $capture_helper->end(); ?>
You can use $content_for_header anywhere in your templates.
NOTE: Beware that content_for is ignored in caches. So you shouldn't use it for elements that are going to be fragment cached.
Method _addVarToView (line 90)