Skip to content

Commit

Permalink
docs/howto: demonstrate file embedding in a module
Browse files Browse the repository at this point in the history
This fixes the howto demonstrating the `@embed()` attribute so that it's
compatible with the module constraint added by
https://cuelang.org/cl/1203264.

Without this, the production site (currently) builds successfully, but
the tip branch doesn't build against the tip of cue-lang/cue.

Preview-Path: /docs/howto/embed-files-in-cue-evaluation/
Signed-off-by: Jonathan Matthews <[email protected]>
Change-Id: I320a5397e9ba2f2b338b6ded4d2e88ab8b27f068
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cuelang.org/+/1203270
Reviewed-by: Paul Jolly <[email protected]>
TryBot-Result: CUEcueckoo <[email protected]>
  • Loading branch information
jpluscplusm committed Oct 30, 2024
1 parent 59ed102 commit 74a384f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
9 changes: 9 additions & 0 deletions content/docs/howto/embed-files-in-cue-evaluation/en.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@ export CUE_EXPERIMENT=embed
{{{end}}}
{{{end}}}

{{{with step}}}
Initialize a CUE module, or use an existing module if that's appropriate in
your situation:

{{{with script "en" "cue mod init"}}}
cue mod init
{{{end}}}
{{{end}}}

{{{with step}}}
Include the `@extern(embed)` directive at the top of each CUE file that uses the
`@embed()` attribute. Use `@embed()` to embed either a single named file, or a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ package site
files: "+OLguupjBfN0UO75A+1+DHxj3FWAC707RjS5PlC0e/Q="
}
multi_step: {
hash: "HL4T04ANCFJCL6JHIMCMIV5R23QQS8FRUVEE81T3G4NMG7N5JJFG===="
scriptHash: "TMVISIT0L7KO7FNL19TJOD1U6C9RHUT0JSTHSN89257P72DP3GVG===="
hash: "0MVJ6P62ONIB4PAECEFPLTEPUFIUJI31QS0G5V6OPISEJH1I1T00===="
scriptHash: "6GLSE1QMLM2LEKB1QURI6OIII8VNOKIK7NPS7UH1PCC8N2UMLROG===="
steps: [{
doc: "#ellipsis 1"
cmd: "cue version"
Expand All @@ -26,6 +26,11 @@ package site
cmd: "export CUE_EXPERIMENT=embed"
exitCode: 0
output: ""
}, {
doc: ""
cmd: "cue mod init"
exitCode: 0
output: ""
}, {
doc: ""
cmd: "cue eval"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@ $ export CUE_EXPERIMENT=embed
{{< /step >}}

{{< step stepNumber="2" >}}
Initialize a CUE module, or use an existing module if that's appropriate in
your situation:

```text { title="TERMINAL" type="terminal" codeToCopy="Y3VlIG1vZCBpbml0" }
$ cue mod init
```
{{< /step >}}

{{< step stepNumber="3" >}}
Include the `@extern(embed)` directive at the top of each CUE file that uses the
`@embed()` attribute. Use `@embed()` to embed either a single named file, or a
glob identifying multiple files:
Expand Down Expand Up @@ -91,7 +100,7 @@ an unknown filename extension can be loaded by adding the
[`cue help filetypes`]({{< relref "docs/reference/command/cue-help-filetypes/" >}}).
{{< /step >}}

{{< step stepNumber="3" >}}
{{< step stepNumber="4" >}}
Export the resulting configuration:

```text { title="TERMINAL" type="terminal" codeToCopy="Y3VlIGV2YWw=" }
Expand Down

0 comments on commit 74a384f

Please sign in to comment.