docs(view): add a runnable foreign writeback example
Move persistence guidance out of the walkthrough into separate static pages. Add examples/foreign-writeback/index.mq.md, which executes a foreign code fence and writes a keyed total slot into its own source.
This commit is contained in:
1 parent
8dcd69412f
commit
5acf026e0c
7 files changed
+112
-46
No files matched your search
@@ -0,0 +1,34 @@
|
||||
---
|
||||
title: Foreign result writeback
|
||||
description: Execute a foreign code fence and persist the result into this .mq.md
|
||||
import foreign:lib/foreign.mq.md
|
||||
import writeback:lib/writeback.mq.md
|
||||
---
|
||||
|
||||
# main
|
||||
|
||||
This is a runnable example, not a screenshot. Run it with:
|
||||
|
||||
```text
|
||||
marqdo run examples/foreign-writeback/index.mq.md
|
||||
```
|
||||
|
||||
The foreign fence below is a normal Marqdo code value. `foreign.run` executes it;
|
||||
`writeback.record` writes the result into a keyed output slot immediately below
|
||||
the call. Re-running replaces only the `total` slot.
|
||||
|
||||
`合计代码` =
|
||||
```python
|
||||
print(950)
|
||||
```
|
||||
|
||||
**结果 = > foreign.run code=`合计代码`**
|
||||
|
||||
**> writeback.record value=`结果` key="total"**
|
||||
<!-- marqdo-out total
|
||||
950
|
||||
-->
|
||||
|
||||
The keyed slot below is generated by the run:
|
||||
|
||||
查看源码,确认 `total` 槽位就在这次 writeback 调用下方。
|
||||
Reference in new issue
Block a user