liquid

package
v0.0.0-...-d39880e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 27, 2026 License: AGPL-3.0, GPL-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
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

func InjectFeedDiscoveryTags(rendered, blogTitle, categorySlug string) string

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

func SanitizeFeedHTML(html, baseURL string) (string, error)

SanitizeFeedHTML prepares post body HTML for emission inside an RSS `<content:encoded>` block or a JSON Feed `content_html` field.

Steps:

  1. Rewrite relative href/src/srcset to absolute URLs against baseURL.
  2. 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/*.
  3. 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

func (*BlogTemplateRenderer) Render

func (r *BlogTemplateRenderer) Render(
	template string,
	data map[string]interface{},
	partials map[string]string,
) (string, error)

Render renders a blog template with the provided data and partials

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL