File tree Expand file tree Collapse file tree 2 files changed +21
-1
lines changed
Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -98,6 +98,21 @@ $alias seq = "a" \
9898print(seq) --> abc
9999```
100100
101+ ## ` $include `
102+
103+ To reuse code for Pluto's parse-time features such as type hinting, you can include a common 'header' file.
104+
105+ ``` pluto norun title="header.pluto"
106+ $declare _VERSION: string
107+ $declare _PVERSION: string
108+ ```
109+
110+ ``` pluto title="index.pluto" run="https://pluto-lang.org/web/#file_names[]=index.pluto&file_contents[]=%24include%20%22header.pluto%22%0A%0Alocal%20_%3A%20number%20%3D%20_VERSION%20--%20type%20mismatch&file_names[]=header.pluto&file_contents[]=%24declare%20_VERSION%3A%20string%0A%24declare%20_PVERSION%3A%20string"
111+ $include "header.pluto"
112+
113+ local _: number = _VERSION -- type mismatch
114+ ```
115+
101116## ` $haltcompiler `
102117
103118This statement will stop the parser processing further code.
Original file line number Diff line number Diff line change @@ -16,7 +16,12 @@ function patchCodeblocks() {
1616 const button = document . createElement ( "button" ) ;
1717 button . textContent = "Try It" ;
1818 button . onclick = ( ) => {
19- window . open ( "https://pluto-lang.org/web/#code=" + encodeURIComponent ( [ ...code . querySelectorAll ( ".code-container .line" ) ] . map ( x => x . textContent ) . join ( "\n" ) ) ) ;
19+ if ( code . hasAttribute ( "run" ) ) {
20+ // Link override for $include
21+ window . open ( code . getAttribute ( "run" ) ) ;
22+ } else {
23+ window . open ( "https://pluto-lang.org/web/#code=" + encodeURIComponent ( [ ...code . querySelectorAll ( ".code-container .line" ) ] . map ( x => x . textContent ) . join ( "\n" ) ) ) ;
24+ }
2025 } ;
2126 div . appendChild ( button ) ;
2227 }
You can’t perform that action at this time.
0 commit comments