Skip to content
Closed
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,21 @@ This extension defines three parser functions:
For valid icon names see https://fontawesome.com/v6/search.

### Styling

* `{{#far:... ...}}` to insert an icon from the FontAwesome Regular font with additional classes
* `{{#fas:... ...}}` to insert an icon from the FontAwesome Solid font with additional classes
* `{{#fab:... ...}}` to insert an icon from the FontAwesome Brands font with additional classes

**Example:**
`{{#fab:wikipedia-w fa-spin}}` will insert a spinning Wikipedia-W

* `{{#far:...|...}}` to insert an icon from the FontAwesome Regular font with additional style
* `{{#fas:...|...}}` to insert an icon from the FontAwesome Solid font with additional style
* `{{#fab:...|...}}` to insert an icon from the FontAwesome Brands font with additional style

**Example:**
`{{#fab:wikipedia-w|color:red; background-color: green; }}` will insert a red Wikipedia-W on a green background

For valid Font Awesome class names see https://docs.fontawesome.com/web/style/styling.

## Professional Support
Expand Down
8 changes: 7 additions & 1 deletion src/IconRenderers/JavascriptRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,13 @@ public function __construct(
public function render( Parser $parser, PPFrame $frame, array $args ): string {
$this->registerRlModule( $parser );

return Html::element( 'i', [ 'class' => [ $this->fontClass, 'fa-' . trim( $frame->expand( $args[ 0 ] ) ) ] ] );
switch (count($args)) {
case "1":
return Html::element( 'i', [ 'class' => [ $this->fontClass, 'fa-' . trim( $frame->expand( $args[ 0 ] ) ) ] ] );
default:
return Html::element( 'i', [ 'class' => [ $this->fontClass, 'fa-' . trim( $frame->expand( $args[ 0 ] ) ) ],
'style' => trim( $frame->expand( $args[ 1 ] ) ) ] );
}
}

private function registerRlModule( Parser $parser ): void {
Expand Down
9 changes: 7 additions & 2 deletions src/IconRenderers/WebfontRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,13 @@ public function __construct(
*/
public function render( Parser $parser, PPFrame $frame, array $args ): string {
$this->registerRlModule( $parser );

return Html::element( 'i', [ 'class' => [ $this->fontClass, 'fa-' . trim( $frame->expand( $args[ 0 ] ) ) ] ] );
switch (count($args)) {
case "1":
return Html::element( 'i', ['class' => [ $this->fontClass, 'fa-' . trim( $frame->expand( $args[ 0 ] ) ) ] ] );
default:
return Html::element( 'i', ['class' => [ $this->fontClass, 'fa-' . trim( $frame->expand( $args[ 0 ] ) ) ],
'style' => trim( $frame->expand( $args[ 1 ] ) ) ] );
}
}

/**
Expand Down
Loading