aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authors-ol <s-ol@users.noreply.github.com>2018-11-14 08:28:58 +0000
committers-ol <s-ol@users.noreply.github.com>2018-11-14 08:28:58 +0000
commit29b78a283273bd2886e07095e6df0d1299121a0c (patch)
tree71883d45517800560a05e1744cce7897f7e8625b
parentadd ag ignore files (diff)
downloadmmm-29b78a283273bd2886e07095e6df0d1299121a0c.tar.gz
mmm-29b78a283273bd2886e07095e6df0d1299121a0c.zip
mmm.component.text takes single argument
-rw-r--r--mmm/component/init.client.moon4
-rw-r--r--mmm/component/init.server.moon13
2 files changed, 14 insertions, 3 deletions
diff --git a/mmm/component/init.client.moon b/mmm/component/init.client.moon
index 19074c5..c72644b 100644
--- a/mmm/component/init.client.moon
+++ b/mmm/component/init.client.moon
@@ -16,8 +16,8 @@ tohtml = (val) ->
else
error "not a Node: #{val}, #{type val}"
--- shorthand to form a text node from strings
-text = (...) -> document\createTextNode table.concat { ... }, ' '
+-- shorthand to form a text node from a string
+text = (str) -> document\createTextNode tostring str
class ReactiveVar
@isinstance: (val) -> 'table' == (type val) and val.subscribe
diff --git a/mmm/component/init.server.moon b/mmm/component/init.server.moon
index dce09e1..300e3d7 100644
--- a/mmm/component/init.server.moon
+++ b/mmm/component/init.server.moon
@@ -17,7 +17,18 @@ tohtml = (val) ->
error "not a Node: #{val}, #{type val}"
-- shorthand to form a text node from strings
-text = (...) -> table.concat { ... }, ' '
+escapes = {
+ '&': '&amp;'
+ '<': '&lt;'
+ '>': '&gt;'
+ '"': '&quot;'
+ "'": '&#39;'
+ '/': '&#47;'
+}
+
+text = (str) ->
+ str = tostring str
+ str\gsub '[}{">/<\'&]', escapes
class ReactiveVar
@isinstance: (val) -> 'table' == (type val) and val.subscribe