Documentation · ViewHelper reference

XSD schema file | vhs master

Render / TemplateViewHelper

Render: Template

Render a template file (with arguments if desired).

Supports passing variables and controlling the format, paths can be overridden and uses the same format as TS settings a' la plugin.tx_myext.view, which means that this can be done (from any extension, not just "foo")

<v:render.template
 file="EXT:foo/Resources/Private/Templates/Action/Show.html"
 variables="{object: customLoadedObject}"
 paths="{v:variable.typoscript(path: 'plugin.tx_foo.view')}"
 format="xml" />

Which would render the "show" action's template from EXT:foo using paths define in that extension's typoscript but using a custom loaded object when rendering the template rather than the object defined by the "Action" controller of EXT:foo. The output would be in XML format and this format would also be respected by Layouts and Partials which are rendered from the Show.html template.

As such this is very similar to Render/RequestViewHelper with two major differences:

  1. A true ControllerContext is not present when rendering which means that links generated in the template should be made always including all parameters from ExtensionName over PluginName through the usual action etc.
  2. The Controller from EXT:foo is not involved in any way, which means that any custom variables the particular template depends on must be added manually through the "variables" argument

Consider using Render/InlineViewHelper if you are rendering templates from the same plugin.

Consider using Render/RequestViewHelper if you require a completely isolated rendering identical to that which takes place when rendering an Extbase plugin's content object. /

  • Tag usage example

    <v:render.template file="NULL" variables="{foo: 'bar'}" format="NULL" paths="{foo: 'bar'}">
    	<!-- tag content - may be ignored! -->
    </v:render.template>
  • Inline usage example

    {v:render.template(file: 'NULL', variables: {foo: 'bar'}, format: 'NULL', paths: {foo: 'bar'})}

Arguments

Argument Description Type
file

Path to template file, EXT:myext/... paths supported

string
format

Optional format of the template(s) being rendered

string
paths

Optional array of arrays of layout and partial root paths, EXT:mypath/... paths supported

array
variables

Optional array of template variables for rendering

array
Required attribute

Revision history

commit e0864b00a995632a623bf8d5d8d4d5f2d4481199
Author: Claus Due <*****@wildside.dk>
Date:   Sat Nov 10 14:20:57 2012 +0100

    [FEATURE] Render / Template ViewHelper
    
    ViewHelper to render a template with custom paths, variables and format.

commit 26cb017377a75a106adc3d2bb2ea92c578e58fbd
Author: Claus Due <*****@wildside.dk>
Date:   Sat Jan 26 15:39:58 2013 +0100

    [DOC] Doc comment for Render / Template ViewHelper

commit 721c261d42d2a910a530745ba54ea6f180de6042
Author: Benjamin Rau <*****@codearts.at>
Date:   Thu Aug 29 15:00:34 2013 +0200

    [BUGFIX] Pass paths through getFileAbsFilename to resolve EXT: prefix

commit da31bad1d9bb058c072ddb5591e8ed907a1ae8e1
Author: Claus Due <*****@namelesscoder.net>
Date:   Tue Dec 31 23:08:37 2013 +0100

    [TASK] Happy new year!

commit d2e531da034976e6db1478eef5a8478595fd16fe
Author: Claus Due <*****@namelesscoder.net>
Date:   Sun Jan 5 00:45:10 2014 +0100

    [TASK] Migrate to using namespace core class names

commit 1caae8408fccb6af764155b67bb42d05493ed1cf
Author: Benjamin Rau <*****@codearts.at>
Date:   Wed Apr 2 14:11:15 2014 +0200

    [BUGFIX] Path to template in doc-comments non standard-conform

commit 52bd6e41ccfef3d8193b350153912a9716e6a087
Author: Benjamin Rau <*****@codearts.at>
Date:   Tue Apr 1 21:09:00 2014 +0200

    [TASK] CGL compliance

commit da7677bc74f14e9a9300e4ba4487e52c3cb97642
Author: Claus Due <*****@namelesscoder.net>
Date:   Sun Apr 20 01:13:33 2014 +0200

    [TASK] Switch to namespaces

commit f16494865266f00f4df185236b7856aa96841039
Author: Xaver Maierhofer <*****@xwissen.info>
Date:   Sat Jun 7 22:58:04 2014 +0200

    [TASK] Replace old namespace and move v:if to v:condition and v:var to v:variable in documentaion and readme

commit 12ff0ddfb8d36c51f2d3befde7ae812177c80d5d
Author: Xaver Maierhofer <*****@xwissen.info>
Date:   Wed Jun 11 00:01:47 2014 +0200

    [TASK] CGL remove use leading backslash
    PHP Docs
    Note that for namespaced names (fully qualified namespace names containing namespace separator, such as Foo\Bar as opposed to global names that do not, such as FooBar),
    the leading backslash is unnecessary and not recommended, as import names must be fully qualified, and are not processed relative to the current namespace.

commit 4981055359c895f3869e5bd878293b3c15ed26e5
Author: Xaver Maierhofer <*****@xwissen.info>
Date:   Sun Jan 18 14:01:04 2015 +0100

    [TASK] CGL - Define classes, params, use imports

commit 8bb2fc5ee124ba19b0a0ab8e061c9a153fc4651f
Author: Xaver Maierhofer <*****@xwissen.info>
Date:   Sun Jan 18 17:56:13 2015 +0100

    [TASK] Reference Copyright to license.md file