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

Commit

Permalink
Merge branch 'release/0.1.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
silentworks committed Apr 3, 2014
2 parents 8c7e0f3 + f0a05ea commit 55752bb
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 17 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,11 @@ Inside your Smarty template you would write:

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

You can easily pass variables that are arrays using the (.) or object using the (->) by doing:
or with the new array syntax:

{urlFor name="hello" options=["name" => "Josh", "age" => "26"]}

You can easily pass variables that are arrays as normal or using the (.):

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

Expand Down
6 changes: 3 additions & 3 deletions Smarty.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @author Andrew Smith
* @link http://www.slimframework.com
* @copyright 2013 Josh Lockhart
* @version 0.1.0
* @version 0.1.2
* @package SlimViews
*
* MIT LICENSE
Expand Down Expand Up @@ -78,9 +78,9 @@ class Smarty extends \Slim\View
*
* This method will output the rendered template content
*
* @param string $template The path to the template, relative to the templates directory.
* @param string $template The path to the template, relative to the templates directory.
* @param null $data
* @return void
* @return string
*/
public function render($template, $data = null)
{
Expand Down
2 changes: 2 additions & 0 deletions SmartyPlugins/function.baseUrl.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
* Type: function
* Name: baseUrl
* Purpose: outputs url for a function with the defined name method
* version 0.1.2
* package SlimViews
* -------------------------------------------------------------
*/
function smarty_function_baseUrl($params, $template)
Expand Down
2 changes: 1 addition & 1 deletion SmartyPlugins/function.siteUrl.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Type: function
* Name: siteUrl
* Purpose: outputs url for a function with the defined name method
* version 0.1.0
* version 0.1.2
* package SlimViews
* -------------------------------------------------------------
*/
Expand Down
25 changes: 18 additions & 7 deletions SmartyPlugins/function.urlFor.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?php
/*
/**
* Smarty plugin
* -------------------------------------------------------------
* File: function.urlFor.php
* Type: function
* Name: urlFor
* Purpose: outputs url for a function with the defined name method
* version 0.1.0
* package SlimViews
* @version 0.1.2
* @package SlimViews
* -------------------------------------------------------------
*/
function smarty_function_urlFor($params, $template)
Expand All @@ -19,10 +19,21 @@ function smarty_function_urlFor($params, $template)

if (isset($params['options']))
{
$options = explode('|', $params['options']);
foreach ($options as $option) {
list($key, $value) = explode('.', $option);
$opts[$key] = $value;
switch (gettype($params['options'])) {
case 'array':
$opts = $params['options'];
break;

case 'string':
$options = explode('|', $params['options']);
foreach ($options as $option) {
list($key, $value) = explode('.', $option);
$opts[$key] = $value;
}
break;

default:
throw new \Exception('Options parameter is of unknown type, provide either string or array');
}

$url = \Slim\Slim::getInstance($appName)->urlFor($name, $opts);
Expand Down
10 changes: 6 additions & 4 deletions Twig.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @author Andrew Smith
* @link http://www.slimframework.com
* @copyright 2013 Josh Lockhart
* @version 0.1.0
* @version 0.1.2
* @package SlimViews
*
* MIT LICENSE
Expand Down Expand Up @@ -77,16 +77,18 @@ class Twig extends \Slim\View
*
* This method will output the rendered template content
*
* @param string $template The path to the Twig template, relative to the Twig templates directory.
* @param string $template The path to the Twig template, relative to the Twig templates directory.
* @param null $data
* @return void
* @return string
*/
public function render($template, $data = null)
{
$env = $this->getInstance();
$parser = $env->loadTemplate($template);

return $parser->render($this->all(), $data);
$data = array_merge($this->all(), (array) $data);

return $parser->render($data);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion TwigExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @author Andrew Smith
* @link http://www.slimframework.com
* @copyright 2013 Josh Lockhart
* @version 0.1.0
* @version 0.1.2
* @package SlimViews
*
* MIT LICENSE
Expand Down

0 comments on commit 55752bb

Please sign in to comment.