本文整理汇总了PHP中AssetModel::HashTag方法的典型用法代码示例。如果您正苦于以下问题:PHP AssetModel::HashTag方法的具体用法?PHP AssetModel::HashTag怎么用?PHP AssetModel::HashTag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AssetModel
的用法示例。
在下文中一共展示了AssetModel::HashTag方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Gdn_Controller__Handler
public function Gdn_Controller__Handler($sender)
{
/**
* Mustache Files
*
* Resolve and add Mustache template files to the output.
*/
$TemplateFiles = self::ResolveStaticResources($this->_TemplateFiles, 'views', array('StripRoot' => false));
if (sizeof($TemplateFiles)) {
ksort($TemplateFiles);
$TemplateDeliveryMode = C('Garden.Template.DeliveryMethod', 'defer');
$ScriptHint = false;
switch ($TemplateDeliveryMode) {
// Consolidated asynchronous or Inline synchronous loading serves the template content directly
case 'consolidate':
case 'inline':
$HashTag = AssetModel::HashTag($TemplateFiles);
$TemplateFile = CombinePaths(array(PATH_CACHE, "stache-{$HashTag}.js"));
if ($TemplateDeliveryMode == 'inline') {
$ScriptHint = 'inline';
}
if (!file_exists($TemplateFile)) {
$TemplateArchiveContents = array();
foreach ($TemplateFiles as $TemplateSrcFile => $TemplateSrcOptions) {
$TemplateName = GetValueR('options.name', $TemplateSrcOptions);
$TemplateRelativeSrc = str_replace(array(PATH_ROOT, DS), array('', '/'), $TemplateSrcFile);
$TemplateArchiveContents[] = array('Name' => $TemplateName, 'URL' => Gdn::Request()->Url($TemplateRelativeSrc, '//'), 'Contents' => file_get_contents($TemplateSrcFile), 'Type' => 'inline');
}
$TemplateArchiveContents = json_encode($TemplateArchiveContents);
$TemplateTempFile = "{$TemplateFile}.tmp";
file_put_contents($TemplateTempFile, "gdn.Template.Register({$TemplateArchiveContents});");
rename($TemplateTempFile, $TemplateFile);
}
break;
// Deferred loading, just registers the templates and allows lazyloading on the client
// Deferred loading, just registers the templates and allows lazyloading on the client
case 'defer':
$HashTag = AssetModel::HashTag($TemplateFiles);
$TemplateFile = CombinePaths(array(PATH_CACHE, "stache-defer-{$HashTag}.js"));
$ScriptHint = 'inline';
if (!file_exists($TemplateFile)) {
$TemplateDeferredContents = array();
$TemplateDeferredContents = array();
foreach ($TemplateFiles as $TemplateSrcFile => $TemplateSrcOptions) {
$TemplateName = GetValueR('options.name', $TemplateSrcOptions);
$TemplateRelativeSrc = str_replace(array(PATH_ROOT, DS), array('', '/'), $TemplateSrcFile);
$TemplateDeferredContents[] = array('Name' => $TemplateName, 'URL' => Gdn::Request()->Url($TemplateRelativeSrc, '//'), 'Type' => 'defer');
}
$TemplateDeferredContents = json_encode($TemplateDeferredContents);
$TemplateTempFile = "{$TemplateFile}.tmp";
file_put_contents($TemplateTempFile, "gdn.Template.Register({$TemplateDeferredContents});");
rename($TemplateTempFile, $TemplateFile);
}
break;
}
if ($TemplateFile && file_exists($TemplateFile)) {
$TemplateSrc = str_replace(array(PATH_ROOT, DS), array('', '/'), $TemplateFile);
$TemplateOptions = array('path' => $TemplateFile);
if ($ScriptHint == 'inline') {
$TemplateOptions['hint'] = 'inline';
}
$this->Head->AddScript($TemplateSrc, 'text/javascript', $TemplateOptions);
}
}
}