on master help sign in
unify docs for /: and /mark/ and improve /; docs
e763beeTed Blackman
docs/arvo/internals/ford/runes.md+52−17
@@ -55,10 +55,45 @@ that horn, and wraps a face around it.
55Example:
55Example:
56```
56```
57/= foo /~ [a=0 b=1]
57/= foo /~ [a=0 b=1]
58+::
58[a.foo b.foo]
59[a.foo b.foo]
59```
60```
60produces: `[0 1]`
61produces: `[0 1]`
61
62
63+### `/:` evaluate at path, and `/<mark>/` render mark at current path
64+
65+`/:` takes a path and a horn, and evaluates the horn with the current path set to the supplied path.
66+`/mar/` renders the mark 'mar' at the current path.
67+
68+Example:
69+```
70+/= hoo-source /: /path/to/hoon-file /hoon/
71+::
72+`@t`hoo-source
73+```
74+
75+produces the text of the hoon file at "/path/to/hoon-file/hoon".
76+
77+`/hoon/` renders the current path using the `%hoon` mark, which in this case
78+passes the contents through unchanged. In general, rendering a file with a
79+mark will potentially run the contents through a series of conversion
80+operations. For details on marks, see the
81+[marks docs](https://urbit.org/docs/arvo/marks).
82+
83+Here's an example that includes a mark conversion:
84+```
85+/= page /: /path/to/html/file /mime/
86+::
87+page
88+
89+:: contents of /path/to/html/file:
90+<html><head><title>My Fascinating Blog</title></head></html>
91+```
92+produces: `[[%text %html ~] 37 '<html><body><div></div></body></html>']`
93+
94+This result includes the MIME type ('text/html'), the content length in bytes,
95+and the HTML itself.
96+
62### `/_` run a horn on each file in the current directory
97### `/_` run a horn on each file in the current directory
63
98
64`/_` takes a horn as an argument. It produces a new horn representing the
99`/_` takes a horn as an argument. It produces a new horn representing the
@@ -70,6 +105,7 @@ the file.
70Example:
105Example:
71```
106```
72/= kids /_ /hoon/
107/= kids /_ /hoon/
108+::
73`(map term cord)`kids
109`(map term cord)`kids
74```
110```
75
111
@@ -77,31 +113,30 @@ produces a value of type `(map term cord)`, where each key is the basename (the
77filename without the prefix), and each value is the result of running the
113filename without the prefix), and each value is the result of running the
78contents of the file through the `%hoon` mark, which validates that it's valid
114contents of the file through the `%hoon` mark, which validates that it's valid
79hoon code and returns it unmodified. So, the resulting map associates basenames
115hoon code and returns it unmodified. So, the resulting map associates basenames
80−with file contents. For more information on marks, see the docs for the
116+with file contents.
81−`/<mark>/` syntax.
82−
83−### `/:` evaluate at path
84−
85−`/:` takes a path and a horn, and evaluates the horn with the current path set to the supplied path.
86−
87−Example:
88−```
89−/= hoo-source /: /path/to/hoon-file /hoon/
90−`@t`hoo-source
91−```
92−
93−produces the text of the hoon file at "/path/to/hoon-file/hoon".
94
117
95### `/;` operate on
118### `/;` operate on
96
119
97`/;` takes a twig and a horn. The twig should evaluate to a gate, which is then slammed
120`/;` takes a twig and a horn. The twig should evaluate to a gate, which is then slammed
98−with the result of the horn.
121+with the result of the horn as its sample.
99
122
100Example:
123Example:
101−
102```
124```
125+/= goo
126+ /; |=({a/@ b/@} +(b))
103−/= goo /; |=({a/@ b/@} +(b)) /~ [a=0 b=1]
127+ /~ [a=0 b=1]
128+::
104goo
129goo
105```
130```
106
131
132+Here's a slightly more complex example with runes that use the filesystem:
133+```
134+/= file-length
135+ /; |=(a/@t (lent (crip a)))
136+ /: /path/to/hoon/file /hoon/
137+::
138+file-length
139+```
140+produces the number of bytes in the file "/path/to/hoon/file."
141+
107produces: `2`
142produces: `2`