Skip to content

generator: Allow more than just strings in templ expressions #609

@kynrai

Description

@kynrai

It is very common to hydrate a template with data, including ints, for say a count

var count int

templ Counter(count int) {
  <div>{ fmt.Sprint(count) }</div>
}

Or something similar.

My proposal is for the simple cases where the entire statement between {} valulates to an int we can just convert to a string, since that operation cannot fail, muct like strconv.Itoa

Is this is silly idea for edge cases? I dont know or is it too niche of a use case? looking for feedback

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsDecisionIssue needs some more discussion so a decision can be madeenhancementNew feature or requestgenerator

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions