mirror of https://github.com/sveltejs/svelte
preprocess self-closing script and style tags (#5082)
parent
4910f5797f
commit
f36b414d30
@ -0,0 +1,12 @@
|
||||
import * as assert from "assert";
|
||||
|
||||
export default {
|
||||
preprocess: {
|
||||
script: ({ content, attributes }) => {
|
||||
assert.equal(content, "");
|
||||
return {
|
||||
code: `console.log("${attributes["the-answer"]}");`
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
@ -0,0 +1 @@
|
||||
<script the-answer="42"/>
|
@ -0,0 +1 @@
|
||||
<script the-answer="42">console.log("42");</script>
|
@ -0,0 +1,12 @@
|
||||
import * as assert from "assert";
|
||||
|
||||
export default {
|
||||
preprocess: {
|
||||
style: ({ content, attributes: { color } }) => {
|
||||
assert.equal(content, "");
|
||||
return {
|
||||
code: `div { color: ${color}; }`
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
@ -0,0 +1,3 @@
|
||||
<div class='brand-color'>$brand</div>
|
||||
|
||||
<style color="red"/>
|
@ -0,0 +1,3 @@
|
||||
<div class='brand-color'>$brand</div>
|
||||
|
||||
<style color="red">div { color: red; }</style>
|
Loading…
Reference in new issue