Clean up compiled PHP coding style.
This commit is contained in:
+16
-17
@@ -240,8 +240,7 @@ class Mustache_Compiler
|
|||||||
$blockFunction = $context->findInBlock(%s);
|
$blockFunction = $context->findInBlock(%s);
|
||||||
if (is_callable($blockFunction)) {
|
if (is_callable($blockFunction)) {
|
||||||
$buffer .= call_user_func($blockFunction, $context);
|
$buffer .= call_user_func($blockFunction, $context);
|
||||||
} else {
|
} else {%s
|
||||||
%s
|
|
||||||
}
|
}
|
||||||
';
|
';
|
||||||
|
|
||||||
@@ -265,10 +264,7 @@ class Mustache_Compiler
|
|||||||
return sprintf($this->prepare(self::BLOCK_VAR, $level), $id, $this->walk($nodes, $level));
|
return sprintf($this->prepare(self::BLOCK_VAR, $level), $id, $this->walk($nodes, $level));
|
||||||
}
|
}
|
||||||
|
|
||||||
const BLOCK_ARG = '
|
const BLOCK_ARG = '$newContext[%s] = array($this, \'block%s\');';
|
||||||
// %s block_arg
|
|
||||||
$newContext[%s] = array($this, \'block%s\');
|
|
||||||
';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate Mustache Template inheritance block argument PHP source.
|
* Generate Mustache Template inheritance block argument PHP source.
|
||||||
@@ -289,16 +285,17 @@ class Mustache_Compiler
|
|||||||
$keystr = var_export($key, true);
|
$keystr = var_export($key, true);
|
||||||
$id = var_export($id, true);
|
$id = var_export($id, true);
|
||||||
|
|
||||||
return sprintf($this->prepare(self::BLOCK_ARG, 1), $keystr, $id, $key);
|
return sprintf($this->prepare(self::BLOCK_ARG, 1), $id, $key);
|
||||||
}
|
}
|
||||||
|
|
||||||
const BLOCK_FUNCTION = 'public function block%s($context) {
|
const BLOCK_FUNCTION = '
|
||||||
$indent = $buffer = \'\';
|
public function block%s($context)
|
||||||
|
{
|
||||||
%s
|
$indent = $buffer = \'\';%s
|
||||||
|
|
||||||
return $buffer;
|
return $buffer;
|
||||||
}';
|
}
|
||||||
|
';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate Mustache Template inheritance block function PHP source.
|
* Generate Mustache Template inheritance block function PHP source.
|
||||||
@@ -309,13 +306,13 @@ class Mustache_Compiler
|
|||||||
*/
|
*/
|
||||||
private function block($nodes)
|
private function block($nodes)
|
||||||
{
|
{
|
||||||
$code = $this->walk($nodes, 1);
|
$code = $this->walk($nodes, 0);
|
||||||
|
|
||||||
$key = ucfirst(md5($code));
|
$key = ucfirst(md5($code));
|
||||||
|
|
||||||
if (!isset($this->blocks[$key])) {
|
if (!isset($this->blocks[$key])) {
|
||||||
$this->blocks[$key] = sprintf($this->prepare(self::BLOCK_FUNCTION, 1), $key, $code);
|
$this->blocks[$key] = sprintf($this->prepare(self::BLOCK_FUNCTION, 0), $key, $code);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $key;
|
return $key;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -349,7 +346,8 @@ class Mustache_Compiler
|
|||||||
}
|
}
|
||||||
|
|
||||||
return $buffer;
|
return $buffer;
|
||||||
}';
|
}
|
||||||
|
';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate Mustache Template section PHP source.
|
* Generate Mustache Template section PHP source.
|
||||||
@@ -399,7 +397,8 @@ class Mustache_Compiler
|
|||||||
$value = $context->%s(%s);%s
|
$value = $context->%s(%s);%s
|
||||||
if (empty($value)) {
|
if (empty($value)) {
|
||||||
%s
|
%s
|
||||||
}';
|
}
|
||||||
|
';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate Mustache Template inverted section PHP source.
|
* Generate Mustache Template inverted section PHP source.
|
||||||
|
|||||||
Reference in New Issue
Block a user