Blame
|
1 | # Include |
||||||
| 2 | ||||||||
| 3 | The `include` embedding transcludes the content of another page, or a single |
|||||||
| 4 | section of it, into the current page. See <https://github.com/redimp/otterwiki/issues/547>. |
|||||||
| 5 | All examples below pull from the [[Embedding/Include/Source]] page. |
|||||||
| 6 | ||||||||
| 7 | --- |
|||||||
| 8 | ||||||||
| 9 | ## Include a whole page |
|||||||
| 10 | ||||||||
| 11 | ``` |
|||||||
| 12 | {{include|src=/Embedding/Include/Source}} |
|||||||
| 13 | ``` |
|||||||
| 14 | ||||||||
| 15 | {{include|src=/Embedding/Include/Source}} |
|||||||
| 16 | ||||||||
| 17 | --- |
|||||||
| 18 | ||||||||
| 19 | ## Include a single section |
|||||||
| 20 | ||||||||
| 21 | Sections are selected by their heading anchor, the same slug used for heading |
|||||||
| 22 | links, independent of the heading level. |
|||||||
| 23 | ||||||||
| 24 | ``` |
|||||||
| 25 | {{include|src=/Embedding/Include/Source|section=installation}} |
|||||||
| 26 | ``` |
|||||||
| 27 | ||||||||
| 28 | {{include|src=/Embedding/Include/Source|section=installation}} |
|||||||
| 29 | ||||||||
| 30 | --- |
|||||||
| 31 | ||||||||
| 32 | ## Include a section without its heading |
|||||||
| 33 | ||||||||
| 34 | Use `heading=false` to drop the section's own heading line and pull in only its |
|||||||
| 35 | body. |
|||||||
| 36 | ||||||||
| 37 | ``` |
|||||||
| 38 | {{include|src=/Embedding/Include/Source|section=subsection|heading=false}} |
|||||||
| 39 | ``` |
|||||||
| 40 | ||||||||
| 41 | {{include|src=/Embedding/Include/Source|section=subsection|heading=false}} |
|||||||
| 42 | ||||||||
| 43 | ## Include a section without its sub-sections |
|||||||
| 44 | ||||||||
| 45 | By default child sections are included. With `children=false` only the content |
|||||||
| 46 | directly below the heading is transcluded (the *Details* sub-section is left |
|||||||
| 47 | out here). |
|||||||
| 48 | ||||||||
| 49 | ``` |
|||||||
| 50 | {{include|src=/Embedding/Include/Source|section=subsection|children=false}} |
|||||||
| 51 | ``` |
|||||||
| 52 | ||||||||
| 53 | {{include|src=/Embedding/Include/Source|section=subsection|children=false}} |
|||||||
| 54 | ||||||||
| 55 | --- |
|||||||
| 56 | ||||||||
| 57 | ## Relative source path |
|||||||
| 58 | ||||||||
| 59 | A `src` that does not start with `/` is resolved relative to the current page, |
|||||||
| 60 | so this page can reach its own sub-pages without spelling out the full path. |
|||||||
| 61 | ||||||||
| 62 | ``` |
|||||||
| 63 | {{include|src=Include/Source|section=introduction}} |
|||||||
| 64 | ``` |
|||||||
| 65 | ||||||||
| 66 | {{include|src=Include/Source|section=introduction}} |
|||||||
| 67 | ||||||||
| 68 | --- |
|||||||
| 69 | ||||||||
| 70 | ## Reusing a snippet |
|||||||
| 71 | ||||||||
| 72 | A common use is a single-source snippet that is maintained once and reused on |
|||||||
| 73 | many pages. |
|||||||
| 74 | ||||||||
| 75 | ``` |
|||||||
| 76 | {{include|src=/Embedding/Include/Snippet}} |
|||||||
| 77 | ``` |
|||||||
| 78 | ||||||||
| 79 | {{include|src=/Embedding/Include/Snippet}} |
|||||||
| 80 | ||||||||
| 81 | --- |
|||||||
| 82 | ||||||||
| 83 | ## Error handling |
|||||||
| 84 | ||||||||
| 85 | An unknown page or section reports an error instead of failing silently; a |
|||||||
| 86 | missing section also lists the anchors that are available. |
|||||||
| 87 | ||||||||
| 88 | ``` |
|||||||
| 89 | {{include|src=/Embedding/Include/Source|section=does-not-exist}} |
|||||||
| 90 | ``` |
|||||||
| 91 | ||||||||
| 92 | {{include|src=/Embedding/Include/Source|section=does-not-exist}} |
|||||||
