Notebook: Moving from Nunjucks to WebC

My notes on migrating an Eleventy blog template to WebC

For the examples below, Nunjucks code is on the left and WebC code is on the right

Indicating where content should go when the file is used as a layout template

{# Nunjucks #}
{{ content | safe }}
<!---- WebC ---->
<template @raw="content" webc:nokeep></template>

Adding global data as text in an element (Assuming data is in /_data/metadata.js or /_data/metadata.json)

<title>{{ metadata.title }}</title>
<title @text="$data.metatdata.title"></title>

Conditional attributes (source)

<a 
    href="/" 
	{% if page.url == "/" %}
		aria-current="page"
	{% endif %}
>{{ metadata.title }}</a>
<a 
    href="/" 
    :aria-current="page.url == '/' ? 'page' : false" 
    @text="metadata.title"
></a>