Spaces after shortcodes

My intent is to have markup in the source file like

The first president of the US was {{< person "George Washington" >}}.

and a shortcode like

<span style="background-color: #ffbfff;">{{.Get 0}}</span>

and have the result have a colorized name of George, followed by the trailing period. However, the code that gets created puts that span on a single line of HTML and the trailing period goes on a separate line of HTML and there’s an added space.

If I go to some trouble to remove the last newline from the shortcode source code, it all works as planned, the added newline doesn’t get inserted in the page source, and everything is hunky dory.

Hi you can use {{- -}} to trim the white space and encoding from the templates. I was using a partial to populate a URL field and new lines from all the code in the partial were returning a %0a in the URL field breaking it. Adding a dash in the beginning like {{- trims all white space to the left and opposite for the right with -}}

Encounter the same problem. I mix this answer with the “-”, in your case is:

<span style="background-color: #ffbfff;">{{ .Get 0 -}}

I don’t know why but it works :wink: