diff --git a/fastn-core/tests/08-static-assets/output/default-A3F82511B3E56D2CD08DBB929668397A7E3F168E807119C8D73E375734010259.js b/fastn-core/tests/08-static-assets/output/default-40B13B1A51BCA0E2E11544F787F9F644BD7079A31FB42B3FCE1DD4683696571A.js
similarity index 99%
rename from fastn-core/tests/08-static-assets/output/default-A3F82511B3E56D2CD08DBB929668397A7E3F168E807119C8D73E375734010259.js
rename to fastn-core/tests/08-static-assets/output/default-40B13B1A51BCA0E2E11544F787F9F644BD7079A31FB42B3FCE1DD4683696571A.js
index 9296645bb3..1fdaf5b16d 100644
--- a/fastn-core/tests/08-static-assets/output/default-A3F82511B3E56D2CD08DBB929668397A7E3F168E807119C8D73E375734010259.js
+++ b/fastn-core/tests/08-static-assets/output/default-40B13B1A51BCA0E2E11544F787F9F644BD7079A31FB42B3FCE1DD4683696571A.js
@@ -4803,7 +4803,6 @@ const ftd = (function () {
return;
}
-
if (body && method !== "GET") {
if (body[0] instanceof fastn.recordInstanceClass) {
if (body.length !== 1) {
diff --git a/fastn-core/tests/08-static-assets/output/index.html b/fastn-core/tests/08-static-assets/output/index.html
index 55e13eb1f7..c0690b219c 100644
--- a/fastn-core/tests/08-static-assets/output/index.html
+++ b/fastn-core/tests/08-static-assets/output/index.html
@@ -14,7 +14,7 @@
-
+
diff --git a/fastn-core/tests/09-markdown-pages/output/default-67B65AF29D66B906BAE293F4937C76B4EF66302B96447D220BBCE10F8122B342.js b/fastn-core/tests/09-markdown-pages/output/default-95E0EBF19DED1675D31D884F2DA8FC8E9CA2DA19F288E98A7B0C4357F1EAA780.js
similarity index 99%
rename from fastn-core/tests/09-markdown-pages/output/default-67B65AF29D66B906BAE293F4937C76B4EF66302B96447D220BBCE10F8122B342.js
rename to fastn-core/tests/09-markdown-pages/output/default-95E0EBF19DED1675D31D884F2DA8FC8E9CA2DA19F288E98A7B0C4357F1EAA780.js
index 7474389749..eaf1f034fd 100644
--- a/fastn-core/tests/09-markdown-pages/output/default-67B65AF29D66B906BAE293F4937C76B4EF66302B96447D220BBCE10F8122B342.js
+++ b/fastn-core/tests/09-markdown-pages/output/default-95E0EBF19DED1675D31D884F2DA8FC8E9CA2DA19F288E98A7B0C4357F1EAA780.js
@@ -4803,7 +4803,6 @@ const ftd = (function () {
return;
}
-
if (body && method !== "GET") {
if (body[0] instanceof fastn.recordInstanceClass) {
if (body.length !== 1) {
diff --git a/fastn-core/tests/09-markdown-pages/output/index.html b/fastn-core/tests/09-markdown-pages/output/index.html
index 22185ce23f..1db8ccd2a8 100644
--- a/fastn-core/tests/09-markdown-pages/output/index.html
+++ b/fastn-core/tests/09-markdown-pages/output/index.html
@@ -14,7 +14,7 @@
-
+
diff --git a/fastn-core/tests/17-sitemap/output/default-D473FE22CBCC050EFA221DFE772E03E5AE70ACD4DBF17D461BF66523DD110CC5.js b/fastn-core/tests/17-sitemap/output/default-00321F81BF756B0FB5A975C4E898A0F1A37462F37F6DC231B85AB35688F315A4.js
similarity index 99%
rename from fastn-core/tests/17-sitemap/output/default-D473FE22CBCC050EFA221DFE772E03E5AE70ACD4DBF17D461BF66523DD110CC5.js
rename to fastn-core/tests/17-sitemap/output/default-00321F81BF756B0FB5A975C4E898A0F1A37462F37F6DC231B85AB35688F315A4.js
index 663626a98e..1ec8048e07 100644
--- a/fastn-core/tests/17-sitemap/output/default-D473FE22CBCC050EFA221DFE772E03E5AE70ACD4DBF17D461BF66523DD110CC5.js
+++ b/fastn-core/tests/17-sitemap/output/default-00321F81BF756B0FB5A975C4E898A0F1A37462F37F6DC231B85AB35688F315A4.js
@@ -4803,7 +4803,6 @@ const ftd = (function () {
return;
}
-
if (body && method !== "GET") {
if (body[0] instanceof fastn.recordInstanceClass) {
if (body.length !== 1) {
diff --git a/fastn-core/tests/17-sitemap/output/guide/install/index.html b/fastn-core/tests/17-sitemap/output/guide/install/index.html
index 8d0da2d44d..84bed8f524 100644
--- a/fastn-core/tests/17-sitemap/output/guide/install/index.html
+++ b/fastn-core/tests/17-sitemap/output/guide/install/index.html
@@ -14,7 +14,7 @@
-
+
diff --git a/fastn-core/tests/17-sitemap/output/index.html b/fastn-core/tests/17-sitemap/output/index.html
index 78def79f8a..7e6849325a 100644
--- a/fastn-core/tests/17-sitemap/output/index.html
+++ b/fastn-core/tests/17-sitemap/output/index.html
@@ -14,7 +14,7 @@
-
+
diff --git a/fastn-core/tests/17-sitemap/output/install/index.html b/fastn-core/tests/17-sitemap/output/install/index.html
index 8d0da2d44d..84bed8f524 100644
--- a/fastn-core/tests/17-sitemap/output/install/index.html
+++ b/fastn-core/tests/17-sitemap/output/install/index.html
@@ -14,7 +14,7 @@
-
+
diff --git a/fastn-core/tests/19-offline-build/output/default-84E5DFDBAA4766EAF977826708AADC9D400114E3917D4F8AEFCFB10D1765DAAB.js b/fastn-core/tests/19-offline-build/output/default-7CB544FFDC631B24C510DFAA21A71343396A1503C8D7883C55CAA350B2B033AD.js
similarity index 99%
rename from fastn-core/tests/19-offline-build/output/default-84E5DFDBAA4766EAF977826708AADC9D400114E3917D4F8AEFCFB10D1765DAAB.js
rename to fastn-core/tests/19-offline-build/output/default-7CB544FFDC631B24C510DFAA21A71343396A1503C8D7883C55CAA350B2B033AD.js
index 3afad0b436..c195981f17 100644
--- a/fastn-core/tests/19-offline-build/output/default-84E5DFDBAA4766EAF977826708AADC9D400114E3917D4F8AEFCFB10D1765DAAB.js
+++ b/fastn-core/tests/19-offline-build/output/default-7CB544FFDC631B24C510DFAA21A71343396A1503C8D7883C55CAA350B2B033AD.js
@@ -4803,7 +4803,6 @@ const ftd = (function () {
return;
}
-
if (body && method !== "GET") {
if (body[0] instanceof fastn.recordInstanceClass) {
if (body.length !== 1) {
diff --git a/fastn-core/tests/19-offline-build/output/index.html b/fastn-core/tests/19-offline-build/output/index.html
index f9c6e50478..457470ce2f 100644
--- a/fastn-core/tests/19-offline-build/output/index.html
+++ b/fastn-core/tests/19-offline-build/output/index.html
@@ -14,9 +14,9 @@
-
+
-
+
@@ -2077,7 +2077,7 @@
name: "John Doe",
title: "Software Developer",
company_name: "John Doe Pvt. Ltd.",
- logo: global.fastn_community_github_io_business_card_demo_assets__files.get("assets").get("ipsum_logo").get("svg"),
+ logo: global.fastn_community_github_io_business_card_demo_assets__files.get("assets_ipsum_logo_svg"),
contact_1: "+91 12345 99999",
contact_2: "+91 12345 88888",
email: "john@johndoe.com",
@@ -2090,42 +2090,42 @@
}
}
global["main"] = main;
-fastn_utils.createNestedObject(global, "fastn_community_github_io_business_card_assets__files.assets.fastn_badge_white.svg", function () {
+fastn_utils.createNestedObject(global, "fastn_community_github_io_business_card_assets__files.assets_fastn_badge_white_svg", function () {
let record = fastn.recordInstance({
});
record.set("light", "-/fastn-community.github.io/business-card/assets/fastn-badge-white.svg");
record.set("dark", "-/fastn-community.github.io/business-card/assets/fastn-badge-white-dark.svg");
return record;
}());
-fastn_utils.createNestedObject(global, "fastn_community_github_io_business_card_assets__files.assets.download_hover.svg", function () {
+fastn_utils.createNestedObject(global, "fastn_community_github_io_business_card_assets__files.assets_download_hover_svg", function () {
let record = fastn.recordInstance({
});
record.set("light", "-/fastn-community.github.io/business-card/assets/download-hover.svg");
record.set("dark", "-/fastn-community.github.io/business-card/assets/download-hover-dark.svg");
return record;
}());
-fastn_utils.createNestedObject(global, "fastn_community_github_io_business_card_assets__files.assets.download.svg", function () {
+fastn_utils.createNestedObject(global, "fastn_community_github_io_business_card_assets__files.assets_download_svg", function () {
let record = fastn.recordInstance({
});
record.set("light", "-/fastn-community.github.io/business-card/assets/download.svg");
record.set("dark", "-/fastn-community.github.io/business-card/assets/download-dark.svg");
return record;
}());
-fastn_utils.createNestedObject(global, "fastn_community_github_io_business_card_assets__files.assets.flip_icon.svg", function () {
+fastn_utils.createNestedObject(global, "fastn_community_github_io_business_card_assets__files.assets_flip_icon_svg", function () {
let record = fastn.recordInstance({
});
record.set("light", "-/fastn-community.github.io/business-card/assets/flip-icon.svg");
record.set("dark", "-/fastn-community.github.io/business-card/assets/flip-icon-dark.svg");
return record;
}());
-fastn_utils.createNestedObject(global, "fastn_community_github_io_business_card_assets__files.assets.flip_icon_hover.svg", function () {
+fastn_utils.createNestedObject(global, "fastn_community_github_io_business_card_assets__files.assets_flip_icon_hover_svg", function () {
let record = fastn.recordInstance({
});
record.set("light", "-/fastn-community.github.io/business-card/assets/flip-icon-hover.svg");
record.set("dark", "-/fastn-community.github.io/business-card/assets/flip-icon-hover-dark.svg");
return record;
}());
-fastn_utils.createNestedObject(global, "fastn_stack_github_io_fastn_js_assets__files.download.js", "-/fastn-stack.github.io/fastn-js/download.js");
+fastn_utils.createNestedObject(global, "fastn_stack_github_io_fastn_js_assets__files.download_js", "-/fastn-stack.github.io/fastn-js/download.js");
let fastn_stack_github_io_fastn_js_utils__download_as_image = function (args)
{
let __fastn_super_package_name__ = __fastn_package_name__;
@@ -2244,7 +2244,7 @@
},
function (root, inherited) {
let rooti0 = fastn_dom.createKernel(root, fastn_dom.ElementKind.Image);
- rooti0.setProperty(fastn_dom.PropertyKind.ImageSrc, global.fastn_community_github_io_business_card_assets__files.get("assets").get("fastn_badge_white").get("svg"), inherited);
+ rooti0.setProperty(fastn_dom.PropertyKind.ImageSrc, global.fastn_community_github_io_business_card_assets__files.get("assets_fastn_badge_white_svg"), inherited);
rooti0.setProperty(fastn_dom.PropertyKind.AlignSelf, fastn_dom.AlignSelf.Center, inherited);
rooti0.setProperty(fastn_dom.PropertyKind.Width, fastn_dom.Resizing.Fixed(fastn_dom.Length.Px(140)), inherited);
rooti0.setProperty(fastn_dom.PropertyKind.MarginTop, fastn_dom.Length.Px(8), inherited);
@@ -2259,15 +2259,15 @@
rooti0.setProperty(fastn_dom.PropertyKind.Spacing, fastn_dom.Spacing.Fixed(fastn_dom.Length.Px(12)), inherited);
rooti0.setProperty(fastn_dom.PropertyKind.Children, fastn.mutableList([function (root, inherited) {
let rooti0 = fastn_dom.createKernel(root, fastn_dom.ElementKind.Image);
- rooti0.setProperty(fastn_dom.PropertyKind.ImageSrc, fastn.formula([global.fastn_community_github_io_business_card_assets__files.get("assets").get("flip_icon_hover").get("svg"),
- global.fastn_community_github_io_business_card_assets__files.get("assets").get("flip_icon").get("svg"),
+ rooti0.setProperty(fastn_dom.PropertyKind.ImageSrc, fastn.formula([global.fastn_community_github_io_business_card_assets__files.get("assets_flip_icon_hover_svg"),
+ global.fastn_community_github_io_business_card_assets__files.get("assets_flip_icon_svg"),
__args__.mouse_in], function () {
if (function () {
return (!fastn_utils.getStaticValue(__args__.mouse_in));
}()) {
- return global.fastn_community_github_io_business_card_assets__files.get("assets").get("flip_icon").get("svg");
+ return global.fastn_community_github_io_business_card_assets__files.get("assets_flip_icon_svg");
} else {
- return global.fastn_community_github_io_business_card_assets__files.get("assets").get("flip_icon_hover").get("svg");
+ return global.fastn_community_github_io_business_card_assets__files.get("assets_flip_icon_hover_svg");
}
}
), inherited);
@@ -2293,15 +2293,15 @@
},
function (root, inherited) {
let rooti0 = fastn_dom.createKernel(root, fastn_dom.ElementKind.Image);
- rooti0.setProperty(fastn_dom.PropertyKind.ImageSrc, fastn.formula([global.fastn_community_github_io_business_card_assets__files.get("assets").get("download").get("svg"),
- global.fastn_community_github_io_business_card_assets__files.get("assets").get("download_hover").get("svg"),
+ rooti0.setProperty(fastn_dom.PropertyKind.ImageSrc, fastn.formula([global.fastn_community_github_io_business_card_assets__files.get("assets_download_svg"),
+ global.fastn_community_github_io_business_card_assets__files.get("assets_download_hover_svg"),
__args__.mouse_over], function () {
if (function () {
return fastn_utils.getStaticValue(__args__.mouse_over);
}()) {
- return global.fastn_community_github_io_business_card_assets__files.get("assets").get("download_hover").get("svg");
+ return global.fastn_community_github_io_business_card_assets__files.get("assets_download_hover_svg");
} else {
- return global.fastn_community_github_io_business_card_assets__files.get("assets").get("download").get("svg");
+ return global.fastn_community_github_io_business_card_assets__files.get("assets_download_svg");
}
}
), inherited);
@@ -2606,7 +2606,7 @@
}
}
global["fastn_community_github_io_business_card__card"] = fastn_community_github_io_business_card__card;
-fastn_utils.createNestedObject(global, "fastn_community_github_io_business_card_demo_assets__files.assets.ipsum_logo.svg", function () {
+fastn_utils.createNestedObject(global, "fastn_community_github_io_business_card_demo_assets__files.assets_ipsum_logo_svg", function () {
let record = fastn.recordInstance({
});
record.set("light", "-/fastn-community.github.io/business-card-demo/assets/ipsum-logo.svg");
diff --git a/fastn-core/tests/21-http-endpoint/output/default-0CA435A480F9408892ACA383C50B3EF2BDE8DBABABFB476CED9CCAE7550067A3.js b/fastn-core/tests/21-http-endpoint/output/default-86C05F0EF1F6C81B1DB99DA46155FD0047BB6E6948676913F2A2C31D2E2457C9.js
similarity index 99%
rename from fastn-core/tests/21-http-endpoint/output/default-0CA435A480F9408892ACA383C50B3EF2BDE8DBABABFB476CED9CCAE7550067A3.js
rename to fastn-core/tests/21-http-endpoint/output/default-86C05F0EF1F6C81B1DB99DA46155FD0047BB6E6948676913F2A2C31D2E2457C9.js
index 5bd0185cbd..8a11e9c7cf 100644
--- a/fastn-core/tests/21-http-endpoint/output/default-0CA435A480F9408892ACA383C50B3EF2BDE8DBABABFB476CED9CCAE7550067A3.js
+++ b/fastn-core/tests/21-http-endpoint/output/default-86C05F0EF1F6C81B1DB99DA46155FD0047BB6E6948676913F2A2C31D2E2457C9.js
@@ -4803,7 +4803,6 @@ const ftd = (function () {
return;
}
-
if (body && method !== "GET") {
if (body[0] instanceof fastn.recordInstanceClass) {
if (body.length !== 1) {
diff --git a/fastn-core/tests/21-http-endpoint/output/index.html b/fastn-core/tests/21-http-endpoint/output/index.html
index ad8e24c4ed..86741165a4 100644
--- a/fastn-core/tests/21-http-endpoint/output/index.html
+++ b/fastn-core/tests/21-http-endpoint/output/index.html
@@ -14,7 +14,7 @@
-
+
diff --git a/fastn-js/src/to_js.rs b/fastn-js/src/to_js.rs
index 83e0ba8602..ddae097c71 100644
--- a/fastn-js/src/to_js.rs
+++ b/fastn-js/src/to_js.rs
@@ -71,7 +71,8 @@ impl fastn_js::SetProperty {
.append(text(
format!(
"{},",
- self.value
+ &self
+ .value
.to_js_with_element_name(&Some(self.element_name.clone()))
)
.as_str(),
@@ -677,6 +678,11 @@ fn variable_to_js(
let (doc_name, remaining) = fastn_js::utils::get_doc_name_and_remaining(variable_name);
let mut name = fastn_js::utils::name_to_js(doc_name.as_str());
if let Some(remaining) = remaining {
+ let remaining = if fastn_js::utils::is_asset_path(doc_name.as_str()) {
+ remaining.replace('.', "_")
+ } else {
+ remaining
+ };
name = format!(
"{}.{}",
name,
diff --git a/fastn-js/src/utils.rs b/fastn-js/src/utils.rs
index f15975f02a..ae0bee0cfe 100644
--- a/fastn-js/src/utils.rs
+++ b/fastn-js/src/utils.rs
@@ -11,7 +11,12 @@ pub fn is_kernel(s: &str) -> bool {
pub fn reference_to_js(s: &str) -> String {
let (prefix, s) = get_prefix(s);
- let (mut p1, mut p2) = get_doc_name_and_remaining(s.as_str());
+ let (mut p1, p2) = get_doc_name_and_remaining(s.as_str());
+ let mut p2 = if is_asset_path(p1.as_str()) {
+ p2.map(|s| s.replace('.', "_"))
+ } else {
+ p2
+ };
p1 = fastn_js::utils::name_to_js_(p1.as_str());
let mut wrapper_function = None;
while let Some(ref remaining) = p2 {
@@ -125,3 +130,15 @@ pub fn trim_brackets(s: &str) -> String {
pub(crate) fn kebab_to_snake_case(s: &str) -> String {
s.replace('-', "_")
}
+
+pub(crate) fn ends_with_exact_suffix(name: &str, separator: &str, suffix: &str) -> bool {
+ if let Some((_, end)) = name.rsplit_once(separator) {
+ end.eq(suffix)
+ } else {
+ false
+ }
+}
+
+pub(crate) fn is_asset_path(name: &str) -> bool {
+ ends_with_exact_suffix(name, "/", "assets#files")
+}
diff --git a/ftd/syntax/neovim-ftd.lua b/neovim-ftd.lua
similarity index 100%
rename from ftd/syntax/neovim-ftd.lua
rename to neovim-ftd.lua