Skip to content
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

Merged
merged 7 commits into from
Oct 25, 2023

Conversation

maximepvrt
Copy link
Contributor

@maximepvrt maximepvrt commented Oct 1, 2023

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' }}.

@@ -65,11 +65,14 @@ const exit = {

// Bindings
function enterBindingContent (this: CompileContext, token: Token) {
const bindingValue = this.sliceSerialize(token).split('|');
Copy link
Collaborator

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?

Copy link
Contributor Author

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!

@maximepvrt
Copy link
Contributor Author

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 !

@farnabaz
Copy link
Collaborator

@maximepvrt Sorry for the late response.
I think using Regexes should be enough.
Do you updating PR and fixing lint? Ping me to merge :)

@maximepvrt
Copy link
Contributor Author

Ok I will add the regex. I started looking at how micromark works for nuxt-modules/mdc#43

@nuxt-studio
Copy link
Contributor

nuxt-studio bot commented Oct 24, 2023

Live Preview ready!

Name Edit Preview Latest Commit
remark-mdc Edit on Studio ↗︎ View Live Preview 126d042

@maximepvrt
Copy link
Contributor Author

@farnabaz PR updated 😉

@farnabaz
Copy link
Collaborator

Thanks For the PR 👍

@farnabaz farnabaz merged commit fc50763 into nuxtlabs:main Oct 25, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants