Skip to content

Instantly share code, notes, and snippets.

@ixv
Created May 23, 2018 00:40
Show Gist options
  • Save ixv/a9e33859a83f0246d54507cd464871f2 to your computer and use it in GitHub Desktop.
Save ixv/a9e33859a83f0246d54507cd464871f2 to your computer and use it in GitHub Desktop.
:- %say
|= *
:- %hymn
=< basic
|%
::::
:::: Replace line 4 with whatever arm your interested in from the core below.
::::
:::: From dojo it may be more useful to call `&html +sail` rather than just `+sail`
:::: not only for readability but because it will expose the nest-failing examples
::
::
:: basics of sail
::
++ basic ;div;
++ with-inner ;div: inner html
++ multi-line ;div
;more: inner
;tags;
==
++ p-insert ;div
with no tag, this line will be wrapped in a <p> tag
==
++ multi-text ;div
; multi
; lines
; with no p tag
==
++ attrs ;div(attr1 "val1", attr2 "val2");
++ id-attr ;div#foo;
++ class-attr ;div.foo;
++ src-attr ;div@"source";
++ href-attr ;div/"source";
++ mixed-attr ;div#foo.bar@"baz"(attr "val");
++ tall-attr ;div
=id "foo"
=class "bar";
::
:: example conditional hoon that produces a manx
::
++ manx-ex ?: &
;true;
;false;
::
:: ;= produces a marl (list of manxs)
::
++ marl-ex ;= ;foo;
;bar;
;baz;
;moo;
==
::
:: tape interpolation
::
++ inter1 ;div: {<(add 2 2)>}
++ inter2 ;div: {"hello"}
++ inter3 ;div
{"a <p> tag is inserted again like in ++p-insert above"}
==
++ sem-hep ;div
;- "this is how to prevent that, note: no need for curly braces here"
==
++ sem-hep-hoon ;div
;- (trip `@t`(mul 8 3.373))
==
::
:: in tall form, a sail tag expects a list of subtags, hence the == terminator
::
:: though its obviously pointless, if we wanted we could use a ;= rather than
:: writing them directly
::
++ ex1 ;div
;= ;a;
;b;
;c;
==
==
::
:: a more sensible example would be using a limb defined elsewhere, which we can
:: do using the ;* rune
::
:: note that the result of ex3 is different from the rest in that a <p> tag is inserted
:: like in ++p-insert above, however ;- will not help in this case, since ;-
:: takes a tape
::
++ ex2 ;div
;* marl-ex
==
++ ex3 ;div
*{marl-ex}
==
++ ex4 ;div: *{marl-ex}
::
:: the following examples, using a manx as a body instead of a marl does not produce a
:: valid manx, which you can confirm by trying to cast the expression to manx
::
++ ex5 ;div
;* manx-ex
==
++ ex6 ;div
*{manx-ex}
==
++ ex7 ;div: *{manx-ex}
::
:: instead to use a manx as a body we must use the ;+ rune
::
++ ex8 ;div
;+ manx-ex
==
++ ex9 ;div
+{manx-ex}
==
++ ex10 ;div: +{manx-ex}
::
:: and likewise, trying to use a marl with the ;+ rune is invalid
::
++ ex11 ;div
;+ marl-ex
==
++ ex12 ;div
+{marl-ex}
==
++ ex13 ;div: +{marl-ex}
--
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment