-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add default value to variable binding #58
feat: add default value to variable binding #58
Conversation
src/from-markdown.ts
Outdated
@@ -65,11 +65,14 @@ const exit = { | |||
|
|||
// Bindings | |||
function enterBindingContent (this: CompileContext, token: Token) { | |||
const bindingValue = this.sliceSerialize(token).split('|'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For me, I prefer to use ||
instead of single |
. This is exactly what you can use in Vue template {{ value || 'default' }}
WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@farnabaz I've been using Twig syntax out of habit, but I agree that the Vue syntax is cleaner. Also, I'm not entirely sure about the proper way to define the start and end of quotes. Could you share some insights on that? Thanks!
Hey @farnabaz. I'd like your advice on whether using a regex to capture the value between quotes is sufficient for isolating the default value, or if I should consider using micromark. Thanks for merging the first part of this issue nuxt-modules/mdc#59 ! |
@maximepvrt Sorry for the late response. |
Ok I will add the regex. I started looking at how micromark works for nuxt-modules/mdc#43 |
✅ Live Preview ready!
|
@farnabaz PR updated 😉 |
Thanks For the PR 👍 |
It enables a convenient syntax for variable binding with default values. Now, you can use the following format in your Markdown documents:
{{ $doc.variable || 'Default Value' }}
.