1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-30 21:40:43 +02:00

Merge pull request #881 from Fyorl/ticket/10970

Allow INCLUDE template macros to accept paths of the form {FOO}/a/{BAR}/c
This commit is contained in:
Nils Adermann
2012-11-10 07:46:50 -08:00
11 changed files with 83 additions and 19 deletions

View File

@@ -23,6 +23,18 @@ class phpbb_template_includephp_test extends phpbb_template_template_test_case
$this->assertEquals("Path is relative to board root.\ntesting included php", $this->display('test'), "Testing INCLUDEPHP");
}
public function test_includephp_variables()
{
$this->setup_engine(array('tpl_allow_php' => true));
$cache_file = $this->template->cachepath . 'includephp_variables.html.php';
$this->run_template('includephp_variables.html', array('TEMPLATES' => 'templates'), array(), array(), "Path includes variables.\ntesting included php", $cache_file);
$this->template->set_filenames(array('test' => 'includephp_variables.html'));
$this->assertEquals("Path includes variables.\ntesting included php", $this->display('test'), "Testing INCLUDEPHP");
}
public function test_includephp_absolute()
{
$path_to_php = dirname(__FILE__) . '/templates/_dummy_include.php.inc';

View File

@@ -20,11 +20,14 @@ class phpbb_template_template_includejs_test extends phpbb_template_template_tes
$scripts = array(
'<script src="' . $this->test_path . '/templates/parent_and_child.js?assets_version=1"></script>',
'<script src="' . $this->test_path . '/parent_templates/parent_only.js?assets_version=1"></script>',
'<script src="' . $this->test_path . '/templates/child_only.js?assets_version=1"></script>'
'<script src="' . $this->test_path . '/templates/child_only.js?assets_version=1"></script>',
'<script src="' . $this->test_path . '/templates/subdir/parent_only.js?assets_version=1"></script>',
'<script src="' . $this->test_path . '/templates/subdir/subsubdir/parent_only.js?assets_version=1"></script>',
'<script src="' . $this->test_path . '/templates/subdir/parent_only.js?assets_version=1"></script>',
);
// Run test
$cache_file = $this->template->cachepath . 'includejs.html.php';
$this->run_template('includejs.html', array('PARENT' => 'parent_only.js'), array(), array(), implode('', $scripts), $cache_file);
$this->run_template('includejs.html', array('PARENT' => 'parent_only.js', 'SUBDIR' => 'subdir', 'EXT' => 'js'), array(), array(), implode('', $scripts), $cache_file);
}
}

View File

@@ -183,6 +183,13 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
array(),
'value',
),
array(
'include_variables.html',
array('SUBDIR' => 'subdir', 'VARIABLE' => 'value'),
array(),
array(),
'value',
),
array(
'loop_vars.html',
array(),

View File

@@ -0,0 +1 @@
<!-- INCLUDE {SUBDIR}/variable.html -->

View File

@@ -2,4 +2,7 @@
<!-- INCLUDEJS {PARENT} -->
<!-- DEFINE $TEST = 'child_only.js' -->
<!-- INCLUDEJS {$TEST} -->
{SCRIPTS}
<!-- INCLUDEJS subdir/{PARENT} -->
<!-- INCLUDEJS {SUBDIR}/subsubdir/{PARENT} -->
<!-- INCLUDEJS {SUBDIR}/parent_only.{EXT} -->
{SCRIPTS}

View File

@@ -0,0 +1,2 @@
Path includes variables.
<!-- INCLUDEPHP ../tests/template/{TEMPLATES}/_dummy_include.php.inc -->

View File

@@ -0,0 +1 @@
{VARIABLE}