(Vegvisir 2, Vegvisir 3)

VV::embed()

Import and inline the contents of any file without executing code.

The syntax is identical to VV::js(), and VV::css().

Description

VV::embed() returns the contents of any file as a string.

Parameters

pathname

Path to a file to embed relative from project root.

relative

Path provided to pathname will be a relative when this parameter is true (default). Set to false to make path absolute.

Return values

string

A string containing the raw contents of the file. File encoding is preserved.

Will return an empty string if the path provided to pathname is not a valid file, or if it failed to import.

Examples

Basic usage

Here is an example the embeds an SVG file directly on a page.

This can come in handy for small icons stored in a separate directory as an example.

By using VV::css() inside a style, we've enabled this stylesheet for that specific page.