Skip to content
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

Commit 55752bb

Browse files
committed
Merge branch 'release/0.1.2'
2 parents 8c7e0f3 + f0a05ea commit 55752bb

7 files changed

Lines changed: 36 additions & 17 deletions

File tree

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,11 @@ Inside your Smarty template you would write:
123123

124124
{urlFor name="hello" options="name.Josh|age.26"}
125125

126-
You can easily pass variables that are arrays using the (.) or object using the (->) by doing:
126+
or with the new array syntax:
127+
128+
{urlFor name="hello" options=["name" => "Josh", "age" => "26"]}
129+
130+
You can easily pass variables that are arrays as normal or using the (.):
127131

128132
<a href="{urlFor name="hello" options="name.{$person.name}|age.{$person.age}"}">Hello {$name}</a>
129133

Smarty.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* @author Andrew Smith
77
* @link http://www.slimframework.com
88
* @copyright 2013 Josh Lockhart
9-
* @version 0.1.0
9+
* @version 0.1.2
1010
* @package SlimViews
1111
*
1212
* MIT LICENSE
@@ -78,9 +78,9 @@ class Smarty extends \Slim\View
7878
*
7979
* This method will output the rendered template content
8080
*
81-
* @param string $template The path to the template, relative to the templates directory.
81+
* @param string $template The path to the template, relative to the templates directory.
8282
* @param null $data
83-
* @return void
83+
* @return string
8484
*/
8585
public function render($template, $data = null)
8686
{

SmartyPlugins/function.baseUrl.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
* Type: function
77
* Name: baseUrl
88
* Purpose: outputs url for a function with the defined name method
9+
* version 0.1.2
10+
* package SlimViews
911
* -------------------------------------------------------------
1012
*/
1113
function smarty_function_baseUrl($params, $template)

SmartyPlugins/function.siteUrl.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Type: function
77
* Name: siteUrl
88
* Purpose: outputs url for a function with the defined name method
9-
* version 0.1.0
9+
* version 0.1.2
1010
* package SlimViews
1111
* -------------------------------------------------------------
1212
*/

SmartyPlugins/function.urlFor.php

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?php
2-
/*
2+
/**
33
* Smarty plugin
44
* -------------------------------------------------------------
55
* File: function.urlFor.php
66
* Type: function
77
* Name: urlFor
88
* Purpose: outputs url for a function with the defined name method
9-
* version 0.1.0
10-
* package SlimViews
9+
* @version 0.1.2
10+
* @package SlimViews
1111
* -------------------------------------------------------------
1212
*/
1313
function smarty_function_urlFor($params, $template)
@@ -19,10 +19,21 @@ function smarty_function_urlFor($params, $template)
1919

2020
if (isset($params['options']))
2121
{
22-
$options = explode('|', $params['options']);
23-
foreach ($options as $option) {
24-
list($key, $value) = explode('.', $option);
25-
$opts[$key] = $value;
22+
switch (gettype($params['options'])) {
23+
case 'array':
24+
$opts = $params['options'];
25+
break;
26+
27+
case 'string':
28+
$options = explode('|', $params['options']);
29+
foreach ($options as $option) {
30+
list($key, $value) = explode('.', $option);
31+
$opts[$key] = $value;
32+
}
33+
break;
34+
35+
default:
36+
throw new \Exception('Options parameter is of unknown type, provide either string or array');
2637
}
2738

2839
$url = \Slim\Slim::getInstance($appName)->urlFor($name, $opts);

Twig.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* @author Andrew Smith
77
* @link http://www.slimframework.com
88
* @copyright 2013 Josh Lockhart
9-
* @version 0.1.0
9+
* @version 0.1.2
1010
* @package SlimViews
1111
*
1212
* MIT LICENSE
@@ -77,16 +77,18 @@ class Twig extends \Slim\View
7777
*
7878
* This method will output the rendered template content
7979
*
80-
* @param string $template The path to the Twig template, relative to the Twig templates directory.
80+
* @param string $template The path to the Twig template, relative to the Twig templates directory.
8181
* @param null $data
82-
* @return void
82+
* @return string
8383
*/
8484
public function render($template, $data = null)
8585
{
8686
$env = $this->getInstance();
8787
$parser = $env->loadTemplate($template);
8888

89-
return $parser->render($this->all(), $data);
89+
$data = array_merge($this->all(), (array) $data);
90+
91+
return $parser->render($data);
9092
}
9193

9294
/**

TwigExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* @author Andrew Smith
77
* @link http://www.slimframework.com
88
* @copyright 2013 Josh Lockhart
9-
* @version 0.1.0
9+
* @version 0.1.2
1010
* @package SlimViews
1111
*
1212
* MIT LICENSE

0 commit comments

Comments
 (0)