SSViewer
class SSViewer implements Flushable (View source)
Parses a template file with an *.ss file extension.
In addition to a full template in the templates/ folder, a template in templates/Content or templates/Layout will be rendered into $Content and $Layout, respectively.
A single template can be parsed by multiple nested {@link SSViewer} instances through $Layout/$Content placeholders, as well as <% include MyTemplateFile %> template commands.
Themes
See http://doc.silverstripe.org/themes and http://doc.silverstripe.org/themes:developing
Caching
Compiled templates are cached via {@link SS_Cache}, usually on the filesystem. If you put ?flush=1 on your URL, it will force the template to be recompiled.
Properties
static private bool | $source_file_comments | ||
static private string | $theme | ||
static private bool | $theme_enabled | ||
static private bool | $rewrite_hash_links |
Methods
Set whether HTML comments indicating the source .SS file used to render this page should be included in the output. This is enabled by default
Triggered early in the request when someone requests a flush.
Create a template from a string instead of a .ss file
Returns the path to the theme folder
Returns an array of theme names present in a directory.
Traverses the given the given class context looking for templates with the relevant name.
Returns the parser that is set for template generation
Returns true if at least one of the listed templates exists.
No description
Call this to disable rewriting of links. This is useful in Ajax applications.
No description
No description
Clears all parsed template files in the cache folder.
Clears all partial cache blocks.
Set the cache object to use when storing / retrieving partial cache blocks.
Get the cache object to use when storing / retrieving partial cache blocks.
Flag whether to include the requirements in this response.
The process() method handles the "meat" of the template processing.
Execute the given template, passing it the given data.
Execute the evaluated string, passing it the given data.
No description
Returns the filenames of the template that will be rendered. It is a map that may contain 'Content' & 'Layout', and will have to contain 'main'
No description
Return an appropriate base tag for the given template.
Details
static
set_source_file_comments(bool $val)
deprecated
deprecated
Set whether HTML comments indicating the source .SS file used to render this page should be included in the output. This is enabled by default
static bool
get_source_file_comments()
deprecated
deprecated
static
flush()
Triggered early in the request when someone requests a flush.
static SSViewer
fromString(string $content, bool|void $cacheTemplate = null)
Create a template from a string instead of a .ss file
static
set_theme(string $theme)
deprecated
deprecated
static string
current_theme()
deprecated
deprecated
static string
get_theme_folder()
Returns the path to the theme folder
static array
get_themes(string $path = null, bool $subthemes = false)
Returns an array of theme names present in a directory.
static string
current_custom_theme()
deprecated
deprecated
static array
get_templates_by_class($className, $suffix = '', $baseClass = null)
Traverses the given the given class context looking for templates with the relevant name.
__construct(string|array $templateList, TemplateParser $parser = null)
setParser(TemplateParser $parser)
Set the template parser that will be used in template generation
TemplateParser
getParser()
Returns the parser that is set for template generation
static bool
hasTemplate(array $templates)
Returns true if at least one of the listed templates exists.
static
setOption(string $optionName, mixed $optionVal)
deprecated
deprecated
Set a global rendering option.
The following options are available:
- rewriteHashlinks: If true (the default), will be rewritten to contain the
current URL. This lets it play nicely with our
tag. - If rewriteHashlinks = 'php' then, a piece of PHP script will be inserted before the hash links: "<?php echo $_SERVER['REQUEST_URI']; ?>". This is useful if you're generating a page that will be saved to a .php file and may be accessed from different URLs.
static mixed
getOption($optionName)
deprecated
deprecated
static
topLevel()
dontRewriteHashlinks()
Call this to disable rewriting of links. This is useful in Ajax applications.
It returns the SSViewer objects, so that you can call new SSViewer("X")->dontRewriteHashlinks()->process();
exists()
static string
getTemplateFileByType(string $identifier, string $type)
static
flush_template_cache(bool $force = false)
Clears all parsed template files in the cache folder.
Can only be called once per request (there may be multiple SSViewer instances).
static
flush_cacheblock_cache(bool $force = false)
Clears all partial cache blocks.
Can only be called once per request (there may be multiple SSViewer instances).
setPartialCacheStore(Zend_Cache_Core $cache)
Set the cache object to use when storing / retrieving partial cache blocks.
Zend_Cache_Core
getPartialCacheStore()
Get the cache object to use when storing / retrieving partial cache blocks.
includeRequirements($incl = true)
Flag whether to include the requirements in this response.
HTMLText
process(ViewableData $item, array|null $arguments = null, SS_Object $inheritedScope = null)
The process() method handles the "meat" of the template processing.
It takes care of caching the output (via {@link SS_Cache}), as well as replacing the special "$Content" and "$Layout" placeholders with their respective subtemplates.
The method injects extra HTML in the header via {@link Requirements::includeInHTML()}.
Note: You can call this method indirectly by {@link ViewableData->renderWith()}.
static string
execute_template(string $template, mixed $data, array $arguments = null, $scope = null)
Execute the given template, passing it the given data.
Used by the <% include %> template tag to process templates.
static string
execute_string(string $content, mixed $data, array $arguments = null)
Execute the evaluated string, passing it the given data.
Used by partial caching to evaluate custom cache keys expressed using template expressions
parseTemplateContent($content, $template = "")
templates()
Returns the filenames of the template that will be rendered. It is a map that may contain 'Content' & 'Layout', and will have to contain 'main'
setTemplateFile(string $type, string $file)
static
get_base_tag($contentGeneratedSoFar)
Return an appropriate base tag for the given template.
It will be closed on an XHTML document, and unclosed on an HTML document.