11ty / webc

Single File Web Components
MIT License
1.32k stars 38 forks source link

Are other template languages allowed inside WebC components? #146

Closed Zearin closed 1 year ago

Zearin commented 1 year ago

Still learning WebC, so sorry if this is a silly question...

In Vue Single-File Components (SFC), you can do something like:

<template lang="pug"> <!-- or other file extension -->
…
</template>

And Vue will parse the component’s markup as Pug (or whatever template language).

I realize that the meaning of <template> in WebC is different than in Vue SFC components (it’s just the literal HTML element).

With that important difference acknowledged, I want to know:

Is it possible to specify a different template language inside of a WebC component for its content?

d3v1an7 commented 1 year ago

Yup, this is possible within a webc component! https://www.11ty.dev/docs/languages/webc/#using-template-syntax-to-generate-content

There are a few examples going both ways (other lang in webc, webc in other lang) in this thread here: https://github.com/11ty/webc/issues/28

zachleat commented 1 year ago

This is an automated message to let you know that a helpful response was posted to your issue and for the health of the repository issue tracker the issue will be closed. This is to help alleviate issues hanging open waiting for a response from the original poster.

If the response works to solve your problem—great! But if you’re still having problems, do not let the issue’s closing deter you if you have additional questions! Post another comment and we will reopen the issue. Thanks!

Zearin commented 1 year ago

Yup, this is possible within a webc component! https://www.11ty.dev/docs/languages/webc/#using-template-syntax-to-generate-content

There are a few examples going both ways (other lang in webc, webc in other lang) in this thread here: #28

Thank you! I did look through the other thread (#28), but it seems mostly focused on loops in WebC.

My hope was that I could use webc:type="11ty" 11ty:type="pug" to help me migrate some Pug-based include files into WebC components.

However, if I read the docs correctly, it looks like Liquid and Nunjucks are (currently) the only supported languages at the moment.

Am I missing something?

Zearin commented 1 year ago

But if you’re still having problems, do not let the issue’s closing deter you if you have additional questions! Post another comment and we will reopen the issue. Thanks!

@zachleat I posted another comment last week, but it’s still closed....