latest
Before Width: | Height: | Size: 37 KiB After Width: | Height: | Size: 37 KiB |
After Width: | Height: | Size: 48 KiB |
Before Width: | Height: | Size: 49 KiB |
Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 33 KiB |
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 36 KiB |
Before Width: | Height: | Size: 50 KiB After Width: | Height: | Size: 39 KiB |
|
@ -297,6 +297,7 @@
|
|||
<li><a href="usage/#Markdown-format-1">Markdown format</a></li>
|
||||
<li><a href="usage/#Script-format-1">Script format</a></li>
|
||||
<li><a href="usage/#Inline-code-1">Inline code</a></li>
|
||||
<li><a href="usage/#Passing-arguments-to-documents-1">Passing arguments to documents</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="publish/#Publishing-to-html-and-pdf-1">Publishing to html and pdf</a><ul>
|
||||
|
|
|
@ -251,6 +251,12 @@
|
|||
</a>
|
||||
</li>
|
||||
|
||||
<li class="anchor">
|
||||
<a title="Passing arguments to documents" href="#passing-arguments-to-documents">
|
||||
Passing arguments to documents
|
||||
</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
|
||||
|
@ -460,6 +466,25 @@ usage: weave.jl <span class="o">[</span>--doctype DOCTYPE<span class="o">]</span
|
|||
<p>syntax. The code will be replaced with the output of running the code. If the code produces figures the filename or base64 encoded string will be added to output e.g. to include a Plots figure in markdown you can use:</p>
|
||||
<div class="code"><pre><span></span><span class="o">!</span><span class="p">[</span><span class="n">A</span> <span class="n">plot</span><span class="p">](</span><span class="err">`</span><span class="n">j</span> <span class="n">plot</span><span class="p">(</span><span class="mi">1</span><span class="o">:</span><span class="mi">10</span><span class="p">)</span><span class="err">`</span><span class="p">)</span>
|
||||
</pre></div>
|
||||
|
||||
|
||||
<p><a id='Passing-arguments-to-documents-1'></a></p>
|
||||
<h2 id="passing-arguments-to-documents">Passing arguments to documents</h2>
|
||||
<p>You can pass arguments as dictionary to the weaved document using the <code>args</code> argument to <code>weave</code>. The dictionary will be available as <code>WEAVE_ARGS</code> variable in the document.</p>
|
||||
<p>This makes it possible to create the same report easily for e.g. different date ranges of input data from a database or from files with similar format giving the filename as input. </p>
|
||||
<p>In order to pass a filename to a document you need call <code>weave</code> using:</p>
|
||||
<div class="code"><pre><span></span><span class="n">weave</span><span class="p">(</span><span class="s">"mydoc.jmd"</span><span class="p">,</span> <span class="n">args</span> <span class="o">=</span> <span class="n">Dict</span><span class="p">(</span><span class="s">"filename"</span> <span class="o">=></span> <span class="s">"somedata.h5"</span><span class="p">))</span>
|
||||
</pre></div>
|
||||
|
||||
|
||||
<p>and you can access the filename from document as follows:</p>
|
||||
<div class="code"><pre><span></span> ```julia
|
||||
print(WEAVE_ARGS["filename"])
|
||||
```
|
||||
</pre></div>
|
||||
|
||||
|
||||
<p>You can use the <code>out_path</code> argument to control the name of the output document.</p>
|
||||
<aside class="copyright" role="note">
|
||||
|
||||
Matti Pastell 2016 –
|
||||
|
|