Skip to content

Commit

Permalink
Support mustache template in Svelte (#2096)
Browse files Browse the repository at this point in the history
This ensures we delegate the handling of `{{}}` in mustache template to
JS lexer.
  • Loading branch information
tancnle authored Dec 23, 2024
1 parent 251423d commit bf007b7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rouge/lexers/svelte.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def initialize(*)
rule %r/}/, Str::Interpol, :pop!

# Allow JS lexer to handle matched curly braces within template
rule(/(?<=^|[^\\])\{.*?(?<=^|[^\\])\}/) do
rule(/(?<=^|[^\\])\{+.*?(?<=^|[^\\])\}+/) do
delegate @js
end

Expand Down
21 changes: 21 additions & 0 deletions spec/visual/samples/svelte
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,24 @@ Hey { name}, check out our { cats.length } cats!
font-size: 2em;
}
</style>

<div class="flex gap-1.5">
<Tooltip
className="w-full relative"
content={$i18n.t(`WebUI will make requests to "{{url}}/api/chat"`, {url})}
placement="top-start"
>
{#if !(config?.enable ?? true)}
<div
class="absolute top-0 bottom-0 left-0 right-0 opacity-60 bg-white dark:bg-gray-900 z-10"
></div>
{/if}

<input
class="w-full text-sm bg-transparent outline-none odl-text-test"
placeholder={$i18n.t('Enter URL (e.g. http://localhost:11434)')}
bind:value={url}
class="w-full text-sm bg-transparent outline-none odl-text-test"
/>
</Tooltip>
</div>

0 comments on commit bf007b7

Please sign in to comment.