11ty / webc

Single File Web Components
MIT License
1.3k stars 36 forks source link

Does `webc:root` work with layouts? #207

Open urob opened 3 weeks ago

urob commented 3 weeks ago

I am trying to use webc:root to add an attribute to the host component of a layout. For instance, in the following example I would like to add class="some-class" to body in the host layout:

_include/base.webc:

<!doctype html>
<html>
  <head> ... </head>
  <body @raw="content"></body>
</html>

page.webc:

---
layout: base.webc
---
<template class="some-class" webc:root>Some content</template>

Conceptually, this seems very similar to the documented purpose of webc:root. Maybe there is a way to make this work already now? Otherwise, this might be a useful feature to support.