本文整理匯總了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);
}
}
}