Documentation
¶
Index ¶
- Constants
- func InjectFeedDiscoveryTags(rendered, blogTitle, categorySlug string) string
- func RenderBlogTemplate(template string, data map[string]interface{}, partials map[string]string) (string, error)
- func RenderBlogTemplateGo(template string, data map[string]interface{}, partials map[string]string) (string, error)
- func SanitizeFeedHTML(html, baseURL string) (string, error)
- type BlogTemplateRenderer
Constants ¶
const ( BlogRenderTimeout = 5 * time.Second BlogMaxTemplateSize = 100 * 1024 // 100KB )
Security limits for blog template rendering (matching V8/LiquidJS limits)
Variables ¶
This section is empty.
Functions ¶
func InjectFeedDiscoveryTags ¶
InjectFeedDiscoveryTags inserts RSS and JSON Feed autodiscovery <link> elements before the closing </head> in the rendered HTML. If </head> is not found, the HTML is returned unchanged.
On category pages pass categorySlug to include the per-category feed links alongside the main feed. Pass empty string for non-category pages.
func RenderBlogTemplate ¶
func RenderBlogTemplate(template string, data map[string]interface{}, partials map[string]string) (string, error)
RenderBlogTemplate renders a Liquid template with the provided data using liquidgo. This uses the Notifuse/liquidgo library with full Shopify-compatible render tag support.
The partials parameter is optional - pass nil if no partials are needed. Partials can be rendered in templates using: {% render 'partial_name' %} or with parameters: {% render 'partial_name', param: value %}
func RenderBlogTemplateGo ¶
func RenderBlogTemplateGo(template string, data map[string]interface{}, partials map[string]string) (string, error)
RenderBlogTemplateGo renders a Liquid template with the provided data using liquidgo This is the drop-in replacement for RenderBlogTemplate (V8 version)
The partials parameter is optional - pass nil if no partials are needed. Partials can be rendered in templates using: {% render 'partial_name' %} or with parameters: {% render 'partial_name', param: value %}
func SanitizeFeedHTML ¶
SanitizeFeedHTML prepares post body HTML for emission inside an RSS `<content:encoded>` block or a JSON Feed `content_html` field.
Steps:
- Rewrite relative href/src/srcset to absolute URLs against baseURL.
- Run through a bluemonday policy that strips <script>, on* handlers, and javascript:/vbscript: URI schemes. data: URIs survive only when the MIME type is image/*.
- Strip C0 control characters that XML 1.0 forbids (keeping TAB/LF/CR).
A blank baseURL is allowed — in that case relative URLs pass through untouched. The policy is constructed once per call because bluemonday policies are not thread-hostile but mutation during use is unsafe.
Types ¶
type BlogTemplateRenderer ¶
type BlogTemplateRenderer struct {
// contains filtered or unexported fields
}
BlogTemplateRenderer renders blog templates using liquidgo (with render tag support)
func NewBlogTemplateRenderer ¶
func NewBlogTemplateRenderer() *BlogTemplateRenderer
NewBlogTemplateRenderer creates a new liquidgo renderer for blog templates