Skip to main content

HtmlModulesFeature

Simple, lightweight and high-performant HTML templating solution

Assembly: ServiceStack.dll​
View Source​
Declaration
public class HtmlModulesFeature : IPlugin, IHasStringId, IHasId<string>

Properties​

Id​

View Source​
Declaration
public string Id { get; }

IgnoreIfError​

View Source​
Declaration
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​
Declaration
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​
Declaration
public List<IHtmlModulesHandler> Handlers { get; set; }

FileContentsResolver​

File Transformer to use when reading files

View Source​
Declaration
public Func<IVirtualFile, string> FileContentsResolver { get; set; }

Modules​

View Source​
Declaration
public List<HtmlModule> Modules { get; set; }

OnConfigure​

View Source​
Declaration
public List<Action<IAppHost, HtmlModule>> OnConfigure { get; set; }

VirtualFiles​

View Source​
Declaration
public IVirtualPathProvider VirtualFiles { get; set; }

FilesTransformer​

File Transformer options

  • defaults to FilesTransformer.Default
  • disable with FileTransformer.None
View Source​
Declaration
public FilesTransformer FilesTransformer { get; set; }

EnableHttpCaching​

Whether to enable ETag HTTP Caching when not in DebugMode

View Source​
Declaration
public bool? EnableHttpCaching { get; set; }

EnableCompression​

Whether to enable cached compressed responses

View Source​
Declaration
public bool? EnableCompression { get; set; }

CacheControl​

The HTTP CacheControl Header to use (default: public, max-age=3600, must-revalidate)

View Source​
Declaration
public string CacheControl { get; set; }

IncludeHtmlLineTransformers​

Whether to include FilesTransformer["html"].LineTransformers in main index.html

View Source​
Declaration
public bool IncludeHtmlLineTransformers { get; set; }

Fields​

DefaultCacheControl​

View Source​
Declaration
public const string DefaultCacheControl = "public, max-age=3600, must-revalidate"

Methods​

Configure(Action<IAppHost, HtmlModule>)​

View Source​
Declaration
public HtmlModulesFeature Configure(Action<IAppHost, HtmlModule> configure)
Returns​

ServiceStack.HtmlModulesFeature

Parameters​
TypeName
System.Action<ServiceStack.IAppHost,ServiceStack.HtmlModule>configure

Register(IAppHost)​

View Source​
Declaration
public void Register(IAppHost appHost)
Parameters​
TypeName
ServiceStack.IAppHostappHost

Flush()​

Flush HtmlModules cache so it's output is recreated on next request

View Source​
Declaration
public void Flush()

Implements​