SSViewer
class SSViewer implements Flushable
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.
Config options
source_file_comments | boolean | ||
theme | string | ||
theme_enabled | boolean | ||
rewrite_hash_links | boolean |
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
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
at line 705
static
set_source_file_comments(boolean $val)
deprecated
deprecated 4.0 Use the "SSViewer.source_file_comments" config setting instead
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
at line 714
static boolean
get_source_file_comments()
deprecated
deprecated 4.0 Use the "SSViewer.source_file_comments" config setting instead
at line 768
static
flush()
Triggered early in the request when someone requests a flush.
at line 780
static SSViewer
fromString(string $content, bool|void $cacheTemplate = null)
Create a template from a string instead of a .ss file
at line 792
static
set_theme(string $theme)
deprecated
deprecated 4.0 Use the "SSViewer.theme" config setting instead
at line 801
static string
current_theme()
deprecated
deprecated 4.0 Use the "SSViewer.theme" config setting instead
at line 811
static string
get_theme_folder()
Returns the path to the theme folder
at line 823
static array
get_themes(string $path = null, bool $subthemes = false)
Returns an array of theme names present in a directory.
at line 844
static string
current_custom_theme()
deprecated
deprecated since version 4.0
at line 858
static array
get_templates_by_class($className, $suffix = '', $baseClass = null)
Traverses the given the given class context looking for templates with the relevant name.
at line 890
__construct($templateList, TemplateParser $parser = null)
at line 926
setParser(TemplateParser $parser)
Set the template parser that will be used in template generation
at line 935
TemplateParser
getParser()
Returns the parser that is set for template generation
at line 950
static boolean
hasTemplate(array $templates)
Returns true if at least one of the listed templates exists.
at line 980
static
setOption(string $optionName, mixed $optionVal)
deprecated
deprecated 4.0 Use the "SSViewer.rewrite_hash_links" config setting instead
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
at line 995
static mixed
getOption(string $optionName)
deprecated
deprecated 4.0 Use the "SSViewer.rewrite_hash_links" config setting instead
at line 1013
static
topLevel()
at line 1031
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();
at line 1037
exists()
at line 1047
static string
getTemplateFileByType(string $identifier, string $type)
at line 1073
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).
at line 1091
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).
at line 1121
setPartialCacheStore(Zend_Cache_Core $cache)
Set the cache object to use when storing / retrieving partial cache blocks.
at line 1130
Zend_Cache_Core
getPartialCacheStore()
Get the cache object to use when storing / retrieving partial cache blocks.
at line 1139
includeRequirements(boolean $incl = true)
Flag whether to include the requirements in this response.
at line 1194
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()}.
at line 1269
static string
execute_template($template, $data, $arguments = null, $scope = null)
Execute the given template, passing it the given data.
Used by the <% include %> template tag to process templates.
at line 1286
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
at line 1293
parseTemplateContent($content, $template = "")
at line 1305
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'
at line 1313
setTemplateFile(string $type, string $file)
at line 1324
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.