Skip to content

Snippets (pre-defined & user definable) #15

@ghetzel

Description

@ghetzel

Feature: Snippets

A mechanism to load pre-defined chunks of text that can be inserted inline to streamline/standardize certain outputs.

<html>
<head>
  <meta charset="utf-8">

  {{ snippet "html-link" "/assets/css/app.js" }}
</head>
</html>

The above template would produce roughly the following output:

<html>
<head>
  <meta charset="utf-8">

  <link rel="stylesheet" href="/assets/css/app.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous">
</head>
</html>

The {{ snippet }} template function would have following signature: snippet NAME [ARGS ..], with arguments being passed into the template, accessible with the param [N] function. In the above example, the SRI checksum would be dynamically calculated from the given argument. In this way, complex standardized blocks of functionality can be composed using snippets.

Configuration Sample

header:
  snippets:
    banner: '<h1 class="hero">Hello There!</h1>'

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions