UserFrosting API

AssetsTemplatePlugin

Generic plugin for template systems. Provides several convenience methods for linking assets within templates.

Tags
author

Alex Weissman (https://alexanderweissman.com)

author

Jordan Mele (https://blog.djmm.me)

todo

JS and CSS convenience methods. (not bundles)

Table of Contents

$assets Assets
__construct() Constructor. mixed
js() Returns HTML ready tags for all assets in the requested JS bundle. string
css() Returns HTML ready tags for all assets in the requested CSS bundle. string
url() Returns URL to asset specified by stream. mixed
convertAttributes() Converts an array of attributes into a form readily usable within XML. string
makeSelfClosingTag() Generates a self closing tag. string
makeRegularTag() Generates a tag pair. string

Properties

Methods

js()

Returns HTML ready tags for all assets in the requested JS bundle.

public js( [ $bundleName : string = 'js/main' ] [, $attributes : array = [] ] ) : string
Parameters
$bundleName : string = 'js/main'

Bundle name.

$attributes : array = []

Attributes generated tags should include.

Return values
string

css()

Returns HTML ready tags for all assets in the requested CSS bundle.

public css( [ $bundleName : string = 'css/main' ] [, $attributes : array = [] ] ) : string
Parameters
$bundleName : string = 'css/main'

Bundle name.

$attributes : array = []

Attributes generated tags should include.

Return values
string

url()

Returns URL to asset specified by stream.

public url( $streamPath : string|string[] ) : mixed
Parameters
$streamPath : string|string[]

A valid stream. EG: 'assets://path.to' or ['assets', 'path.to']

Return values
mixed

convertAttributes()

Converts an array of attributes into a form readily usable within XML.

private convertAttributes( $attributes : array ) : string
Parameters
$attributes : array

Attributes to convert.

Return values
string

makeSelfClosingTag()

Generates a self closing tag.

private makeSelfClosingTag( $tagName : string [, $attributes : array|null = null ] ) : string
Parameters
$tagName : string

Tag name.

$attributes : array|null = null

Attributes to add to tag. Optional.

Return values
string

makeRegularTag()

Generates a tag pair.

private makeRegularTag( $tagName : string [, $attributes : array|null = null ] [, $content : string = '' ] ) : string
Parameters
$tagName : string

Tag name.

$attributes : array|null = null

Attributes to add to tag. Optional.

$content : string = ''

Content generated tags will wrap around.

Return values
string

Search results