HtmlModulesFeature
Simple, lightweight and high-performant HTML templating solution
Assembly: ServiceStack.dll
View Source
public class HtmlModulesFeature : IPlugin, IHasStringId, IHasId<string>
Properties
Id
View Source
public string Id { get; }
IgnoreIfError
View Source
public bool IgnoreIfError { get; set; }
Tokens
Define literal tokens to be replaced with dynamic fragments, e.g: <base href=""> = ctx => $"<base href=\"{ctx.Request.ResolveAbsoluteUrl($"~{DirPath}/")}\">"
View Source
public Dictionary<string, Func<HtmlModuleContext, ReadOnlyMemory<byte>>> Tokens { get; set; }
Handlers
Define custom html handlers, e.g: <!--shared:Brand,Input--> <!--file:/path/to/single.html--> or /file:/path/to/single.txt/ <!--files:/dir/components/.html--> or /files:/dir/.css/
View Source
public List<IHtmlModulesHandler> Handlers { get; set; }
FileContentsResolver
File Transformer to use when reading files
View Source
public Func<IVirtualFile, string> FileContentsResolver { get; set; }
Modules
View Source
public List<HtmlModule> Modules { get; set; }
OnConfigure
View Source
public List<Action<IAppHost, HtmlModule>> OnConfigure { get; set; }
VirtualFiles
View Source
public IVirtualPathProvider VirtualFiles { get; set; }
FilesTransformer
File Transformer options
- defaults to FilesTransformer.Default
- disable with FileTransformer.None
View Source
public FilesTransformer FilesTransformer { get; set; }
EnableHttpCaching
Whether to enable ETag HTTP Caching when not in DebugMode
View Source
public bool? EnableHttpCaching { get; set; }
EnableCompression
Whether to enable cached compressed responses
View Source
public bool? EnableCompression { get; set; }
CacheControl
The HTTP CacheControl Header to use (default: public, max-age=3600, must-revalidate)
View Source
public string CacheControl { get; set; }
IncludeHtmlLineTransformers
Whether to include FilesTransformer["html"].LineTransformers in main index.html
View Source
public bool IncludeHtmlLineTransformers { get; set; }
Fields
DefaultCacheControl
View Source
public const string DefaultCacheControl = "public, max-age=3600, must-revalidate"
Methods
Configure(Action<IAppHost, HtmlModule>)
View Source
public HtmlModulesFeature Configure(Action<IAppHost, HtmlModule> configure)
Returns
ServiceStack.HtmlModulesFeature
Parameters
Type | Name |
---|---|
System.Action<ServiceStack.IAppHost,ServiceStack.HtmlModule> | configure |
Register(IAppHost)
View Source
public void Register(IAppHost appHost)
Parameters
Type | Name |
---|---|
ServiceStack.IAppHost | appHost |
Flush()
Flush HtmlModules cache so it's output is recreated on next request
View Source
public void Flush()