predominant / TwigView

Twig for CakePHP
http://cakealot.com
MIT License
78 stars 31 forks source link

HtmlHelper array params #21

Open ponyjoy opened 10 years ago

ponyjoy commented 10 years ago

in the template file:

<a href = "{{ html.url({'controller' : 'category', 'action' : 'edit'}) }}"> Edit </a>

render ==>

<a href = "/category/edit"> Edit </a>

It's right.

<a href = "{{ html.url({'controller' : 'category', 'action' : 'edit', 'id' : 1}) }}"> Edit </a>

render ==>

<a href = "/category/edit/id:1"> Edit </a>

this is not desirable, I need like this:

<a href = "/category/edit/1"> Edit </a>

so I change it to

<a href = "{{ html.url({'controller' : 'category', 'action' : 'edit', 1}) }}"> Edit </a>

got error: A hash key must be followed by a colon (:). Unexpected token "punctuation" of value "." ("punctuation" expected with value ":")

in ctp view file, we can use like this:

echo $this->Html->url(array('controller' => 'category', 'action' => 'edit', 1));

How to resolve it ?

mchiron commented 10 years ago

You should be able to use a numeral as the key instead of nothing.

<a href = "{{ html.url({'controller' : 'category', 'action' : 'edit', '0' : 1}) }}"> Edit </a>