Help us shape the future of Go! Take the 2026 Go Developer Survey

testscriptexpressions

package
v0.3.1100 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 26, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllTests

func AllTests() templ.Component

func RenderAfterHTMLOpenComment added in v0.3.1100

func RenderAfterHTMLOpenComment(data string) templ.Component

RenderAfterHTMLOpenComment covers <!--, which comments out the rest of the line in a classic script, so the quote after it does not start a string.

func RenderAfterIfCondition added in v0.3.1100

func RenderAfterIfCondition(data string) templ.Component

RenderAfterIfCondition covers a '/' after the condition of an if statement, which starts a regular expression. If the tokenizer reads it as division, the quote in the regular expression is read as the start of a string, and data in code is escaped as string content, so that it executes.

func RenderAfterNumberWithTrailingDecimalPoint added in v0.3.1100

func RenderAfterNumberWithTrailingDecimalPoint(data string) templ.Component

RenderAfterNumberWithTrailingDecimalPoint covers a '/' after a number that ends with a decimal point, which is division. If the tokenizer reads the '.' as a property access, the '/' starts a regular expression, the quote in the string after it is skipped, and data in code is escaped as string content, so that it executes.

func RenderAfterPostfixIncrement added in v0.3.1100

func RenderAfterPostfixIncrement(data string) templ.Component

RenderAfterPostfixIncrement covers a '/' after a postfix increment, which is division.

func RenderAfterPropertyNamedReturn added in v0.3.1100

func RenderAfterPropertyNamedReturn(data string) templ.Component

RenderAfterPropertyNamedReturn covers a '/' after a property named return, which is division. If the tokenizer reads it as a regular expression, the quote in the string after it is skipped, and data in code is escaped as string content, so that it executes.

func RenderAtRegexpStart added in v0.3.1100

func RenderAtRegexpStart(data string) templ.Component

RenderAtRegexpStart covers data at the start of a regular expression literal, where empty data would join the opening '/' to the next character.

func RenderAtRegexpStartBeforeQuantifier added in v0.3.1100

func RenderAtRegexpStartBeforeQuantifier(data string) templ.Component

RenderAtRegexpStartBeforeQuantifier covers data at the start of a regular expression literal that is followed by '*', where empty data would start a block comment.

func RenderInRegexp added in v0.3.1100

func RenderInRegexp(data string) templ.Component

RenderInRegexp covers data in a regular expression literal. JSON encoding does not escape '/', so data in a regular expression must be escaped as string content, which escapes '/' and '\', so that it can't end the regular expression.

func RenderInRegexpAfterHTMLOpenComment added in v0.3.1100

func RenderInRegexpAfterHTMLOpenComment(data string) templ.Component

RenderInRegexpAfterHTMLOpenComment covers data in a regular expression after <!--, where a <script> start tag would stop </script> from ending the element.

func RenderInRegexpClass added in v0.3.1100

func RenderInRegexpClass(data string) templ.Component

RenderInRegexpClass covers data in a character class, where empty data must stay empty, so that no characters are added to the class.

func Script

func Script[T any](name string, data T) templ.Component

func ScriptTemplateLiteralSubstitution added in v0.3.1100

func ScriptTemplateLiteralSubstitution[T any](name string, data T) templ.Component

ScriptTemplateLiteralSubstitution covers GHSA-jq3r-rjqp-mwgj: a Go expression inside a `${ ... }` substitution of a backtick quoted template literal is in JavaScript expression position, so it must be JSON encoded like any other expression, rather than escaped as string data.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL