Skip to content

Commit

Permalink
feat(directives): allow escape char in class name (#1151)
Browse files Browse the repository at this point in the history
  • Loading branch information
hannoeru committed Jun 24, 2022
1 parent b11f2cb commit 9fba115
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/transformer-directives/src/index.ts
Expand Up @@ -83,7 +83,10 @@ export async function transformDirectives(
if (!body)
return

const classNames = expandVariantGroup(body).split(/\s+/g)
const classNames = expandVariantGroup(body)
.split(/\s+/g)
.map(className => className.trim().replace(/\\/, ''))

const utils = (
await Promise.all(
classNames.map(i => uno.parseToken(i, '-')),
Expand Down
13 changes: 13 additions & 0 deletions test/transformer-directives.test.ts
Expand Up @@ -468,4 +468,17 @@ describe('transformer-directives', () => {
`)
})
})

test('escape backslash', async () => {
const result = await transform(
'.btn { @apply border-r-\$theme-color }',
)
expect(result)
.toMatchInlineSnapshot(`
".btn {
border-right-color: var(--theme-color);
}
"
`)
})
})

0 comments on commit 9fba115

Please sign in to comment.