Skip to content

NamePolicy context

const NamePolicyContext: ComponentContext<NamePolicy<string>>
import { useNamePolicy } from "@alloy-js/core";
const myContext = useNamePolicy();
for(TElements | undefined) => NamePolicyGetter

Get a function that takes a name and applies the naming policy to it.

getName(string, TElements | undefined) => string

Apply the language policy to the provided name for the provided element type.

import { createNamePolicy } from "@alloy-js/core";
function createNamePolicy<T extends string>(namer: (name: string, elements: T) => string): NamePolicy<T>;