Learn how Scrivito CMS can help you deliver amazing digital experiences
See Scrivito CMS in action
New in 1.26.0

resolveHtmlUrls(htmlString)

Transforms internal URLs contained in raw Scrivito HTML markup to fully qualified URLs.

Scrivito.resolveHtmlUrls(htmlString);

For the purpose of customizing (processing) the contents of html attributes and rendering it, this method resolves the internal URLs the markup may contain.

Params

  • htmlString (String) – Raw Scrivito HTML markup, typically from an attribute of the html type.

Returns

String – The HTML markup with all internal links resolved to fully qualified URLs.

Examples

Retrieve the HTML markup of all text widgets on the current page:

await Scrivito.load(() => Scrivito.currentPage() .widgets() .filter((w) => w.objClass() === "TextWidget") .map((w) => Scrivito.resolveHtmlUrls(w.get("text"))) );

Render an html attribute with resolved internal URLs and filled-in placeholders:

<div dangerouslySetInnerHTML={{ __html: Scrivito.resolveHtmlUrls(widget.get('body')).replaceAll( '$name', 'Jane Smith' ), }} />