Commit 57022c2d by Seldaek

* Include allows paths going in upper levels now such as : "../foo.html"

git-svn-id: svn://dwoo.org/dwoo/trunk@123 0598d79b-80c4-4d41-97ba-ac86fbbd088b
parent e3eb1b76
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
{a http://url.com; "Text" /} which equals to {a http://url.com}Text{/} {a http://url.com; "Text" /} which equals to {a http://url.com}Text{/}
+ Syntax: Block plugins that you want to call without content can be + Syntax: Block plugins that you want to call without content can be
self-closed just like XML tags (e.g. {a "http://url.com" /} ). Be careful not self-closed just like XML tags (e.g. {a "http://url.com" /} ). Be careful not
to close a non-block plugin like that however, since it will close it's to close a non-block plugin like that however, since it will close it's
parent block parent block
+ Plugins: Added the {a} block plugin to generate <a> tags + Plugins: Added the {a} block plugin to generate <a> tags
+ API: Added Dwoo_Plugin::paramsToAttributes() utility function to help + API: Added Dwoo_Plugin::paramsToAttributes() utility function to help
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
=> http://forum.dwoo.org/viewtopic.php?id=50 => http://forum.dwoo.org/viewtopic.php?id=50
* Compiler now allows the use of the right delimiter inside strings (e.g. {"}"}) * Compiler now allows the use of the right delimiter inside strings (e.g. {"}"})
* Fixed a bug preventing if blocks containing a {elseif} followed by {else} * Fixed a bug preventing if blocks containing a {elseif} followed by {else}
* Include allows paths going in upper levels now such as : "../foo.html"
[2008-06-28] 0.9.2 [2008-06-28] 0.9.2
! BC Break: Renamed the {strip} modifier/function to {whitespace}, this does ! BC Break: Renamed the {strip} modifier/function to {whitespace}, this does
......
...@@ -59,6 +59,10 @@ function Dwoo_Plugin_include(Dwoo $dwoo, $file, $cache_time = null, $cache_id = ...@@ -59,6 +59,10 @@ function Dwoo_Plugin_include(Dwoo $dwoo, $file, $cache_time = null, $cache_id =
} }
} }
if ($resource === 'file' && strpos($identifier, '..') !== false) {
$identifier = realpath(dirname($dwoo->getTemplate()->getResourceIdentifier()) . DIRECTORY_SEPARATOR . $identifier);
}
try { try {
$include = $dwoo->templateFactory($resource, $identifier, $cache_time, $cache_id, $compile_id); $include = $dwoo->templateFactory($resource, $identifier, $cache_time, $cache_id, $compile_id);
} catch (Dwoo_Exception $e) { } catch (Dwoo_Exception $e) {
......
...@@ -243,6 +243,14 @@ class FuncTests extends PHPUnit_Framework_TestCase ...@@ -243,6 +243,14 @@ class FuncTests extends PHPUnit_Framework_TestCase
$this->assertEquals("34", $this->dwoo->get($tpl, array(), $this->compiler)); $this->assertEquals("34", $this->dwoo->get($tpl, array(), $this->compiler));
} }
public function testIncludeParent()
{
$tpl = new Dwoo_Template_File(TEST_DIRECTORY.'/resources/subfolder/inctest.html');
$tpl->forceCompilation();
$this->assertEquals("43", $this->dwoo->get($tpl, array(), $this->compiler));
}
public function testIndent() public function testIndent()
{ {
$tpl = new Dwoo_Template_String('{indent $foo 6 "-"}'); $tpl = new Dwoo_Template_String('{indent $foo 6 "-"}');
......
{include file="../test.html" foo=4 bar=3}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment