Skip to content

Add alignment argument to svg shortcode

Sietze van Buuren requested to merge wip/buu1sh/improve-svg-shortcode into master

This commit adds an alignment argument to the svg short-code, in order to make it more flexible. This allows to e.g. align an svg image to the left. With this change, all svg shortcode input arguments are now named:

  • src: svg file location (required)
  • alignment: image alignment (optional, default: "center")

The current (old) implementation uses one positional argument (the svg file location), whereas the (new) implementation in this commit uses two named arguments. It is not possible to keep the first positional argument and add one named argument, since Hugo does not allow to mix named and positional arguments. Therefore, this short-code is not backwards compatible and all existing svg short-code calls will have to be updated, when adopting this change!

At least the first argument should be supplied as named argument. Thus, old code like:

{{< svg "/path/to/svg-file" >}}

should be replaced with

{{< svg src="/path/to/svg-file" >}}

or

{{< svg src="/path/to/svg-file" alignment="left" >}}

if one wants to override the default alignment.

Signed-off-by: default avatarSietze van Buuren Sietze.vanBuuren@de.bosch.com

Edited by Sietze van Buuren

Merge request reports

Loading