diff options
| author | s-ol <s-ol@users.noreply.github.com> | 2018-11-14 08:28:58 +0000 |
|---|---|---|
| committer | s-ol <s-ol@users.noreply.github.com> | 2018-11-14 08:28:58 +0000 |
| commit | 29b78a283273bd2886e07095e6df0d1299121a0c (patch) | |
| tree | 71883d45517800560a05e1744cce7897f7e8625b | |
| parent | add ag ignore files (diff) | |
| download | mmm-29b78a283273bd2886e07095e6df0d1299121a0c.tar.gz mmm-29b78a283273bd2886e07095e6df0d1299121a0c.zip | |
mmm.component.text takes single argument
| -rw-r--r-- | mmm/component/init.client.moon | 4 | ||||
| -rw-r--r-- | mmm/component/init.server.moon | 13 |
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 = { + '&': '&' + '<': '<' + '>': '>' + '"': '"' + "'": ''' + '/': '/' +} + +text = (str) -> + str = tostring str + str\gsub '[}{">/<\'&]', escapes class ReactiveVar @isinstance: (val) -> 'table' == (type val) and val.subscribe |
