Skip to content

Add fn::template and fn::eval ESC builtin function docs#18613

Merged
CamSoper merged 2 commits intomasterfrom
pterradillos/esc-fn-template-eval-docs
Apr 22, 2026
Merged

Add fn::template and fn::eval ESC builtin function docs#18613
CamSoper merged 2 commits intomasterfrom
pterradillos/esc-fn-template-eval-docs

Conversation

@tehsis
Copy link
Copy Markdown
Contributor

@tehsis tehsis commented Apr 20, 2026

Summary

  • Adds documentation for two new ESC built-in functions: fn::template and fn::eval
  • fn::template defines a template expression with deferred interpolation
  • fn::eval evaluates a template in the context of the calling environment, enabling late binding across environments
  • Updates the builtin functions index page and adjusts menu weights to maintain alphabetical ordering

Feature dependency

Must be merged after pulumi/esc#638

🤖 Generated with Claude Code

Documents the new late-binding feature that allows defining reusable
template expressions in one environment and evaluating them with
different values in consumer environments.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@claude
Copy link
Copy Markdown
Contributor

claude Bot commented Apr 20, 2026

Docs review — #18613

Thanks for the new fn::template and fn::eval pages! The structure mirrors the existing builtin-function pages, headings follow title/sentence-case conventions, both new files end with newlines, and the menu weight cascade in the other function pages is correctly aligned. The _index.md insertions also preserve alphabetical order. A few items to address before merge:

Issues

1. Incorrect separator in implicit-import reference (fn-eval.md, line 25)

The parameters table shows ${environments.org/defn.my-template} using a / between project and environment. Every other page in this directory — and the examples further down in this same file and in fn-template.md — uses a dot for that separator (${environments.PROJECT.ENV.VALUEPATH}, documented in content/docs/esc/environments/imports.md line 103). The / form is the syntax used in an imports: list, not inside a ${environments.…} interpolation.

Suggested fix:

| `template-reference` | any  | A reference to a value defined with `fn::template`. Typically an interpolation like `${environments.org.defn.my-template}`. |

2. Hyphenated key in interpolation path (fn-template.md, lines 73 and 85)

The second example defines resource-name: and then references it as ${environments.org.templates.resource-name}. Every interpolation path elsewhere in the ESC docs uses simple or camelCase identifiers (aws.dev.aws.region, rotatorExample.managingCredentials.managingUser, etc.), and dots inside a reference are parsed as path separators, so a hyphenated segment at the end of a path is worth confirming against the ESC implementation. If this works as written, great; if not, consider renaming the key to resourceName to match the style used in the rest of the reference docs.

3. meta_desc wording (fn-eval.md, line 5)

Minor: the body text (line 13) correctly describes evaluation happening in the calling environment, but the meta_desc says "in the context of the current environment," which can read as the defining environment. Consider aligning both:

meta_desc: The fn::eval built-in function evaluates a template expression in the context of the calling environment.

Nits (non-blocking)

  • Trailing slashes on internal links. fn-eval.md line 13/92 and fn-template.md line 13/101 link to /docs/…/fn-template/ and /docs/…/fn-eval/ with a trailing slash, while _index.md lists them without. Both resolve, but picking one convention per directory is cleaner.
  • "Related functions" section. Nice addition — none of the other builtin function pages have one today. If it's useful here, consider backfilling fn::fromBase64/fn::toBase64, fn::toJSON/fn::fromJSON, fn::validate/fn::open, etc. in a follow-up.
  • Example namespace. Most ESC examples use the myorg//myproj/ prefixes (see fn-final.md, fn-validate.md, imports.md). The new files use example/ and org/; aligning to myorg/ would match conventions.

Verified

  • Alphabetical order preserved in _index.md
  • Menu weights cascade correctly (2→15 across 14 pages)
  • Front matter fields present (title, title_tag, h1, meta_desc, menu)
  • New files end with a newline
  • YAML examples are syntactically valid
  • Heading casing (H1 code identifiers, H2+ sentence case)
  • No new build/infrastructure changes that would require BUILD-AND-DEPLOY.md updates

Mention @claude if you'd like another pass after changes.

@pulumi-bot
Copy link
Copy Markdown
Collaborator

pulumi-bot commented Apr 20, 2026

Replace slash with dot in the environment reference example to match
ESC implicit-import syntax (${environments.PROJECT.ENV.VALUEPATH}).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@CamSoper CamSoper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docs look great — the examples match the late-binding test fixture on pulumi/esc@claire/defns byte-for-byte, and the narrative around late binding is clear.

I pushed one small fix: fn-eval.md had ${environments.org/defn.my-template} in the parameter description, which should be ${environments.org.defn.my-template} to match the implicit-import syntax documented in content/docs/esc/environments/imports.md and used by your other examples in the same file.

One thing worth double-checking before merge: the implementation is still on the claire/defns feature branch on pulumi/esc (HEAD is a WIP commit from Feb 2025, not merged to main). Are these functions shipping in an upcoming ESC release that lines up with these docs going live? If there's any gap, we may want a preview/experimental callout or to hold the merge until the ESC PR lands.

@CamSoper
Copy link
Copy Markdown
Contributor

@tehsis Merging, LMK if more work needs to be done.

@CamSoper CamSoper merged commit 2c76a53 into master Apr 22, 2026
8 checks passed
@CamSoper CamSoper deleted the pterradillos/esc-fn-template-eval-docs branch April 22, 2026 19:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants