本文整理汇总了PHP中League\Plates\Engine::getFileExtension方法的典型用法代码示例。如果您正苦于以下问题:PHP Engine::getFileExtension方法的具体用法?PHP Engine::getFileExtension怎么用?PHP Engine::getFileExtension使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类League\Plates\Engine
的用法示例。
在下文中一共展示了Engine::getFileExtension方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: path
/**
* Resolve template path.
* @return string
*/
public function path()
{
if (is_null($this->folder)) {
$path = $this->engine->getDirectory() . DIRECTORY_SEPARATOR . $this->file;
} else {
$path = $this->folder->getPath() . DIRECTORY_SEPARATOR . $this->file;
if (!is_file($path) and $this->folder->getFallback() and is_file($this->engine->getDirectory() . DIRECTORY_SEPARATOR . $this->file)) {
$path = $this->engine->getDirectory() . DIRECTORY_SEPARATOR . $this->file;
}
}
if (!is_null($this->engine->getFileExtension())) {
$path .= '.' . $this->engine->getFileExtension();
}
return $path;
}
示例2: render
/**
* Render a string
*
* @param string $template The template content to render
* @param array $locals The variable to use in template
* @return null|string
*/
public function render($template, array $locals = array())
{
$tmpName = uniqid('plates_tmp_', false);
$tmpPath = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $tmpName;
if (!is_null($this->plates->getFileExtension())) {
$tmpPath .= '.' . $this->plates->getFileExtension();
}
$isTmpRegister = $this->plates->getFolders()->exists(sys_get_temp_dir());
if (!$isTmpRegister) {
$this->plates->addFolder(sys_get_temp_dir(), sys_get_temp_dir());
}
file_put_contents($tmpPath, $template);
$data = $this->plates->render(sys_get_temp_dir() . '::' . $tmpName, $locals);
unlink($tmpPath);
if (!$isTmpRegister) {
$this->plates->getFolders()->remove(sys_get_temp_dir());
}
return $data;
}
示例3: setFile
/**
* Set the parsed template file.
* @param string $file
* @return Name
*/
public function setFile($file)
{
if ($file === '') {
throw new LogicException('The template name "' . $this->name . '" is not valid. ' . 'The template name cannot be empty.');
}
$this->file = $file;
if (!is_null($this->engine->getFileExtension())) {
$this->file .= '.' . $this->engine->getFileExtension();
}
return $this;
}