Skip to content

Commit 7052e1e

Browse files
committed
Added interpunct support to replace hyphens.
1 parent 1e62ef0 commit 7052e1e

File tree

3 files changed

+19
-11
lines changed

3 files changed

+19
-11
lines changed

docs/app.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -366,21 +366,22 @@ const contentNav =
366366
),
367367
div.class`mt-6 pl-3`(
368368
/* Place this tag where you want the button to render. */
369-
a.class`github-button`.href`https://github.com/mudgen/webscript`
370-
["data-size"]`large`
371-
["data-show-count"]`true`
372-
["aria-label"]`Star Webscript on GitHub``Star`,
369+
a.class`github-button`
370+
.href`https://github.com/mudgen/webscript`
371+
.data·size`large`
372+
.data·show·count`true`
373+
.aria·label`Star Webscript on GitHub``Star`,
373374
div.class`mt-2`(
374375
a.class`github-button`.href`https://github.com/sponsors/mudgen`
375-
["data-size"]`large`
376-
["data-icon"]`octicon-heart`
377-
["ariaLabel"]`Sponsor @ntkme on GitHub``Sponsor`
376+
.data·size`large`
377+
.data·icon`octicon-heart`
378+
.aria·label`Sponsor @mudgen on GitHub``Sponsor`
378379
),
379380
div.class`mt-2`(
380381
a.class`twitter-follow-button`.href`https://twitter.com/mudgen?ref_src=twsrc%5Etfw`
381-
["data-size"]`large`
382-
["data-show-count"]`false`
383-
["data-show-screen-name"]`false`
382+
.data·size`large`
383+
.data·show·count`false`
384+
.data·show·screen·name`false`
384385
`Follow @mudgen`
385386
)
386387
),

html2webscript/app.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,8 @@ function out(o, indent) {
346346
}
347347
}
348348

349+
let hyphen = new RegExp("-","g");
350+
349351
function camelCase(hyphenText) {
350352
return hyphenText.split("-")
351353
.map((text, index) => {
@@ -375,7 +377,7 @@ function traverse(element) {
375377
else {
376378
let name = a.name;
377379
if (name.indexOf('-') > -1) {
378-
name = camelCase(name);
380+
name = name.replace(hyphen, "·");
379381
}
380382
o.attrs.push(`.${name}\`${a.value}\``);
381383
}

src/webscript.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ function templateValues(args) {
1313
return result;
1414
}
1515

16+
let interpunct = new RegExp("·","g");
17+
1618
function createInitialBuilder(constructor, type) {
1719
function setPropertyValue(...args) {
1820
let [value] = args;
@@ -73,6 +75,9 @@ function createInitialBuilder(constructor, type) {
7375
return setPropsValues;
7476
}
7577
else if (typeof prop === "string") {
78+
if(prop.indexOf("·") !== -1) {
79+
prop = prop.replace(interpunct, "-");
80+
}
7681
if (prop.endsWith("Value") && prop.length > 5) {
7782
return target.__element_info__.props[prop.slice(0, -5)];
7883
}

0 commit comments

Comments
 (0)