Permalink
Browse files

fixes for include

  • Loading branch information...
tthomas48 committed Mar 18, 2013
1 parent de54239 commit da89284bb457579adb05582751c6772f1971b0ee
Showing with 25 additions and 4 deletions.
  1. +1 −1 HTML/Template/Nest/Compiler.php
  2. +1 −1 HTML/Template/Nest/Tag.php
  3. +23 −2 HTML/Template/Nest/Taglib/Standard.php
@@ -54,6 +54,7 @@ class HTML_Template_Nest_Compiler extends php_user_filter
public function __construct() {
stream_filter_register("nst.filter", "HTML_Template_Nest_Compiler");
+ $this->parser = new HTML_Template_Nest_Parser();
}
function filter($in, $out, &$consumed, $closing) {
@@ -100,7 +101,6 @@ public function compile($filename, $contents = NULL)
$output = "";
try {
- $this->parser = new HTML_Template_Nest_Parser();
if($contents == NULL) {
$contents = file_get_contents($filename);
}
@@ -54,7 +54,7 @@ class HTML_Template_Nest_Tag
protected $attributes;
protected $declaredAttributes = array();
protected $attributeTypes = array();
- private $id;
+ protected $id;
/**
* Constructor
@@ -431,6 +431,7 @@ public function filter($output)
}
class HTML_Template_Nest_Taglib_Standard_IncludeTag extends HTML_Template_Nest_Tag
{
+ private $newCompiler;
public function start()
{
$file = $this->getRequiredAttribute("name");
@@ -443,7 +444,27 @@ public function start()
if($viewPath == NULL) {
throw new HTML_Template_Nest_TagException("Unable to find include $file in path.", $this->node);
}
- $compiler = new HTML_Template_Nest_Compiler();
- return $compiler->compile($viewPath);
+
+ $output = "<?php ";
+ $this->newCompiler = new HTML_Template_Nest_Compiler();
+ foreach($this->attributes as $key => $value) {
+ if($key == 'name') {
+ continue;
+ }
+ $this->newCompiler->parser->registerVariable($this->id, $key);
+
+ $value = $this->compiler->parser->parse($value, false, "\"");
+ $output .= "\$" . $this->newCompiler->parser->getLocalVariableName($key) . " = \"" . $value . "\";\n";
+ }
+ $output .= "?>";
+ return $output . $this->newCompiler->compile($viewPath);
+ }
+ public function end() {
+ foreach($this->attributes as $key => $value) {
+ if($key == 'name') {
+ continue;
+ }
+ $this->newCompiler->parser->unregisterVariable($this->id, $key);
+ }
}
}

0 comments on commit da89284

Please sign in to comment.