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

Auto templating #52

Merged
merged 19 commits into from
Feb 25, 2024
Merged

Auto templating #52

merged 19 commits into from
Feb 25, 2024

Conversation

adnaan
Copy link
Collaborator

@adnaan adnaan commented Feb 25, 2024

Extract template from html elements with a fir event namespace.

Instead of

<div @fir:[inc:ok,dec:ok]::count="$fir.replace()">
    {{ block "count" . }}
    <div>Count: {{ .count }}</div>
    {{ end }}
</div>

do this

 <div @fir:[inc:ok,dec:ok]="$fir.replace()">
    Count: {{ .count }}
 </div>

Under the hood, an automatic template is extracted. The output html looks like this:

<div 
  @fir:inc:ok::fir-03f6dd43146caaa8="$fir.replace()" 
  @fir:dec:ok::fir-03f6dd43146caaa8="$fir.replace()" >
        Count: 0
</div>

where fir-03f6dd43146caaa8 is the name of the extracted template. This means one can continue to use the ::template syntax for out of band append, prepend operations.

Moreover now one needs to explicitly add a modifier .nohtmlto ensure no template is bound to an event. Incidentally this is also useful status signaling. e.g.

 @fir:create-tweet:ok.nohtml="$refs.createTweet.reset()"

resets the createTweet form.

Also updated examples to accommodate the above change.

@adnaan adnaan marked this pull request as draft February 25, 2024 02:03
@adnaan adnaan marked this pull request as ready for review February 25, 2024 03:31
@adnaan adnaan merged commit 7734c84 into main Feb 25, 2024
@adnaan adnaan deleted the auto_templating branch February 25, 2024 03:31
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.

1 participant