Skip to content

Commit

Permalink
[TASK] Replace old namespace and move v:if to v:condition and v:var t…
Browse files Browse the repository at this point in the history
…o v:variable in documentaion and readme
  • Loading branch information
xf- committed Jun 7, 2014
1 parent 6066c80 commit f164948
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,18 @@
* ### Examples
*
* <!-- simple usage, content becomes then-child -->
* <v:if.context.isFrontend>
* <v:condition.context.isFrontend>
* Hooray for BE contexts!
* </v:if.context.isFrontend>
* </v:condition.context.isFrontend>
* <!-- extended use combined with f:then and f:else -->
* <v:if.context.isFrontend>
* <v:condition.context.isFrontend>
* <f:then>
* Hooray for BE contexts!
* </f:then>
* <f:else>
* Maybe BE, maybe CLI.
* </f:else>
* </v:if.context.isFrontend>
* </v:condition.context.isFrontend>
*
* @author Claus Due <claus@namelesscoder.net>
* @package Vhs
Expand Down
2 changes: 1 addition & 1 deletion Classes/ViewHelpers/Render/TemplateViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
* <v:render.template
* file="EXT:foo/Resources/Private/Templates/Action/Show.html"
* variables="{object: customLoadedObject}"
* paths="{v:var.typoscript(path: 'plugin.tx_foo.view')}"
* paths="{v:variable.typoscript(path: 'plugin.tx_foo.view')}"
* format="xml" />
*
* Which would render the "show" action's template from
Expand Down
2 changes: 1 addition & 1 deletion Classes/ViewHelpers/TryViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
* <!-- assume that the variable {badJson} contains the string "DontDecodeMe"
* which if course is invalid JSON and cannot be decoded. The default
* behavior is to simply output a simple "cannot decode" string. -->
* <v:var.set name="decodedBadJson" value="{badJson -> v:format.json.decode()}" />
* <v:variable.set name="decodedBadJson" value="{badJson -> v:format.json.decode()}" />
* Displayed only if the JSON decode worked. Much more code and many more
* ViewHelpers can go here. Now, imagine that this block spans so much code
* that potentially there could come an Exception from many additional places
Expand Down
14 changes: 7 additions & 7 deletions Classes/ViewHelpers/Variable/GetViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,16 @@
* ViewHelper used to read the value of a current template
* variable. Can be used with dynamic indices in arrays:
*
* <v:var.get name="array.{dynamicIndex}" />
* <v:var.get name="array.{v:var.get(name: 'arrayOfSelectedKeys.{indexInArray}')}" />
* <f:for each="{v:var.get(name: 'object.arrayProperty.{dynamicIndex}')}" as="nestedObject">
* <v:variable.get name="array.{dynamicIndex}" />
* <v:variable.get name="array.{v:var.get(name: 'arrayOfSelectedKeys.{indexInArray}')}" />
* <f:for each="{v:variable.get(name: 'object.arrayProperty.{dynamicIndex}')}" as="nestedObject">
* ...
* </f:for>
*
* Or to read names of variables which contain dynamic parts:
*
* <!-- if {variableName} is "Name", outputs value of {dynamicName} -->
* {v:var.get(name: 'dynamic{variableName}')}
* {v:variable.get(name: 'dynamic{variableName}')}
*
* @author Claus Due <claus@namelesscoder.net>
* @package Vhs
Expand All @@ -58,12 +58,12 @@ class GetViewHelper extends AbstractViewHelper {
*
* Can be used to access dynamic variables such as:
*
* {v:var.get(name: 'object.arrayProperty.{index}')}
* {v:variable.get(name: 'object.arrayProperty.{index}')}
*
* And can be chained with `v:var.set` to reassign the
* And can be chained with `v:variable.set` to reassign the
* output to another variable:
*
* {v:var.get(name: 'myArray.{index}') -> v:var.set(name: 'myVar')}
* {v:variable.get(name: 'myArray.{index}') -> v:var.set(name: 'myVar')}
*
* If your target object is an array with unsequential yet
* numeric indices (e.g. {123: 'value1', 513: 'value2'},
Expand Down
10 changes: 5 additions & 5 deletions Classes/ViewHelpers/Variable/SetViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@
* Sets a single variable in the TemplateVariableContainer
* scope. The variable then becomes accessible as {var}.
*
* Combines well with `v:var.get` to set shorter variable
* Combines well with `v:variable.get` to set shorter variable
* names referencing dynamic variables, such as:
*
* <v:var.set name="myObject" value="{v:var.get(name: 'arrayVariable.{offset}')}" />
* <v:variable.set name="myObject" value="{v:var.get(name: 'arrayVariable.{offset}')}" />
* <!-- If {index} == 4 then {myObject} is now == {arrayVariable.4} -->
* {myObject.name} <!-- corresponds to {arrayVariable.4.name} -->
*
Expand All @@ -46,14 +46,14 @@
*
* In many ways this ViewHelper works like `f:alias`
* with one exception: in `f:alias` the variable only
* becomes accessible in the tag content, whereas `v:var.set`
* becomes accessible in the tag content, whereas `v:variable.set`
* inserts the variable in the template and leaves it there
* (it "leaks" the variable).
*
* If $name contains a dot, VHS will attempt to load the object
* stored under the named used as the first segment part and
* set the value at the remaining path. E.g.
* `{value -> v:var.set(name: 'object.property.subProperty')}`
* `{value -> v:variable.set(name: 'object.property.subProperty')}`
* would attempt to load `{object}` first, then set
* `property.subProperty` on that object/array using
* ObjectAccess::setPropertyPath(). If `{object}` is not
Expand All @@ -64,7 +64,7 @@
* must first extract the second-level object then set the
* value on that object.
*
* Using as `{value -> v:var.set(name: 'myVar')}` makes `{myVar}` contain
* Using as `{value -> v:variable.set(name: 'myVar')}` makes `{myVar}` contain
* `{value}`.
*
* @author Claus Due <claus@namelesscoder.net>
Expand Down
4 changes: 2 additions & 2 deletions Classes/ViewHelpers/Variable/TyposcriptViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
* into two variables usable for a menu item:
*
* <!-- This piece to be added as far up as possible in order to prevent multiple executions -->
* <v:var.set name="menuSettings" value="{v:var.typoscript(path: 'lib.menu.main.stdWrap')}" />
* <v:var.set name="wrap" value="{menuSettings.wrap -> v:iterator.explode(glue: '|')}" />
* <v:variable.set name="menuSettings" value="{v:var.typoscript(path: 'lib.menu.main.stdWrap')}" />
* <v:variable.set name="wrap" value="{menuSettings.wrap -> v:iterator.explode(glue: '|')}" />
*
* <!-- This in the loop which renders the menu (see "VHS: manual menu rendering" in FAQ): -->
* {wrap.0}{menuItem.title}{wrap.1}
Expand Down
6 changes: 3 additions & 3 deletions Classes/ViewHelpers/Variable/UnsetViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,19 @@
*
* <!-- Data: {person: {name: 'Elvis', nick: 'King'}} -->
* I'm {person.name}. Call me "{person.nick}". A ding-dang doo!
* <v:var.unset name="person" />
* <v:variable.unset name="person" />
* <f:if condition="{person}">
* <f:else>
* You saw this coming...
* <em>Elvis has left the building</em>
* </f:else>
* </f:if>
*
* At the time of writing this, `v:var.unset` is not able
* At the time of writing this, `v:variable.unset` is not able
* to remove members of for example arrays:
*
* <!-- DOES NOT WORK! -->
* <v:var.unset name="myObject.propertyName" />
* <v:variable.unset name="myObject.propertyName" />
*
* @author Claus Due <claus@namelesscoder.net>
* @package Vhs
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ the image path but manually creating an `<img />` tag and using `f:uri.image` as
To use the ViewHelpers in your Fluid templates simply add the namespace:

```xml
{namespace v=Tx_Vhs_ViewHelpers}
{namespace v=FluidTYPO3\Vhs\ViewHelpers}
```

Using the namespace name "v" is not required but it is recommended. It's a single character
Expand Down

0 comments on commit f164948

Please sign in to comment.