Closed jaymakes11 closed 3 years ago
An implementation that should not need as much of a rework could be:
---
import { Pug } from 'astro/components';
---
<Pug>
h1 Hello!
p this is a test
</Pug>
and just pass along all frontmatter vars to pug (could use #1107 if that is not feasible)
But having .pug
files treated similar to markdown files (and exposing Astro.props to them for dynamic stuff) would also work
Honestly, I was wondering when somebody was going to create an issue about this, Lol
Not a solution, but your JSX could be a lot easier:
{x ? (<h1>Heading if x is true</h1>) : (<h1>Heading if x is false</h1>)}
But I do understand your point.
How would you do stuff like frontmatter scripts? This doesn't seem to be valid Pug:
---
import Checkbox from '../components/Checkbox.astro';
---
Checkbox(
type='checkbox'
name='agreement'
checked
)
How would you do stuff like frontmatter scripts? This doesn't seem to be valid Pug [...]
My initial thinking is that the Pug markup would exist in the context of a <template lang="pug">
tag (with a lang
attribute), in a similar way that Vue, Svelte, and others approach it.
However, it'd be nice if we could simply write Pug in place of Html in the way that .astro files current support Html. For this I imagine there'd have to be some type of Astro-level config flag (I suppose either set globally in the asto config file or on a per-file basis). But if going this route I think we'd need new editor integration for proper syntax highlighting and such (that's one benefit of the <template lang="pug">
approach.
Hey everyone! Our current RFC process is beginning to break down at this size, with over 50 open RFCs currently in the "discussing" stage. A growing community is a great problem to have, but our ability to give you RFC feedback has suffered as a result. In an effort to improve our RFC process, we are making some changes to better organize things.
From now on, all RFCs will live in a standalone repo: https://github.com/withastro/rfcs
This allows us to do three things: 1) Use threaded discussions for high-level ideas and improvements, without necessarily requiring an implementation for every idea. 2) Improve the quality of our RFC template and the speed/quality of all feedback. 3) Support inline comments and explicit approvals on RFCs, via a new Pull Request review process.
We hope that this new process leads to better RFC weekly calls and faster feedback on your RFCs from maintainers. More detail can be found in the new RFC repo README.
We can't automatically convert this issue to an RFC in the new repo because new RFC template is more detailed that this one. But, you can still continue this discussion in the new repo by creating a new Discussion in the RFC repo and copy-and-pasting this post (and any relevant follow-up comments) into it. Discussions are available for high-level ideas and suggestions without the requirement of a full implementation proposal.
Then, when you are ready to propose (or re-propose) an implementation for feedback and approval, you can create a new RFC using the new RFC template. More detail about how to do this can be found in the new RFC repo README.
Thanks for your patience as we attempt to improve things for both authors and reviewers. If you have any questions, don't hesitate to reach out on Discord. https://astro.build/chat
Hi guys.
Any news on the support of Pug ?
I don't see anything mentioning Pug in the RFCs
BTW, @jaymakes11 @degouville @Tc-001
I created a discussion for a proposal to add first class support for Pug in astro files: https://github.com/withastro/roadmap/discussions/885
Background & Motivation
I've used Pug for years. I prefer it because life is too short to waste it closing opening tags (yes, I'm looking at you, HTML). Beyond the improved authoring experience, however, It also provides a higher signal-to-noise ratio when reading template code, which is more of a benefit than I think a lot of people may realize.
Astro seems to get so many things right (and I'm especially excited for the improvements coming in 0.21). So much so that I've even bit the bullet and begun converting Pug templates from an existing project into HTML to migrate to Astro. But boy oh boy has this been painful. It feels like a regression (going from Pug to HTML).
I should point out here that the pain isn't just having to write HTML instead of Pug. It's also the JSX(ish) nature of conditionals in templates. Going from this
to this
just feels incredibly wrong.
If Astro offered first-class support for Pug in
.astro
files it may become the closest-to-perfect SSG in existence (just sayin').Note: I mean no disrespect to any who really like HTML or JSX or the current state of templating in Astro!
Risks, downsides, and/or tradeoffs
More complexity in the codebase is the only real tradeoff I see.
Open Questions
Help make it happen!
Note: First brought this up in Discord (https://discord.com/channels/830184174198718474/830184175176122389/895568380592029727).