Skip to content

Commit bf007b7

Browse files
authored
Support mustache template in Svelte (rouge-ruby#2096)
This ensures we delegate the handling of `{{}}` in mustache template to JS lexer.
1 parent 251423d commit bf007b7

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

lib/rouge/lexers/svelte.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def initialize(*)
6262
rule %r/}/, Str::Interpol, :pop!
6363

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

spec/visual/samples/svelte

+21
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,24 @@ Hey { name}, check out our { cats.length } cats!
7676
font-size: 2em;
7777
}
7878
</style>
79+
80+
<div class="flex gap-1.5">
81+
<Tooltip
82+
className="w-full relative"
83+
content={$i18n.t(`WebUI will make requests to "{{url}}/api/chat"`, {url})}
84+
placement="top-start"
85+
>
86+
{#if !(config?.enable ?? true)}
87+
<div
88+
class="absolute top-0 bottom-0 left-0 right-0 opacity-60 bg-white dark:bg-gray-900 z-10"
89+
></div>
90+
{/if}
91+
92+
<input
93+
class="w-full text-sm bg-transparent outline-none odl-text-test"
94+
placeholder={$i18n.t('Enter URL (e.g. http://localhost:11434)')}
95+
bind:value={url}
96+
class="w-full text-sm bg-transparent outline-none odl-text-test"
97+
/>
98+
</Tooltip>
99+
</div>

0 commit comments

Comments
 (0)