Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add inline shortcode support #5471

Merged
merged 2 commits into from
Nov 27, 2018
Merged

Add inline shortcode support #5471

merged 2 commits into from
Nov 27, 2018

Conversation

bep
Copy link
Member

@bep bep commented Nov 26, 2018

Fixes #4011

@bep bep force-pushed the inline-shortcodes branch 5 times, most recently from aa8014b to 07c078a Compare November 27, 2018 12:38
An inline shortcode's name must end with `.inline`, all lowercase.

E.g.:

```bash
{{< time.inline >}}{{ now }}{{< /time.inline >}}
```

The above will print the current date and time.

Note that an inline shortcode's inner content is parsed and executed as a Go text template with the same context as a regular shortcode template.

This means that the current page can be accessed via `.Page.Title` etc. This also means that there are no concept of "nested inline shortcodes".

The same inline shortcode can be reused later in the same content file, with different params if needed, using the self-closing syntax:

```
{{< time.inline />}}
```

Fixes gohugoio#4011
@bep bep force-pushed the inline-shortcodes branch from 07c078a to 07c264c Compare November 27, 2018 13:21
@bep bep changed the title WORK IN PROGRESS: Add inline shortcode support Add inline shortcode support Nov 27, 2018
@bep bep merged commit aded0f2 into gohugoio:master Nov 27, 2018
@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 31, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add "inline" shortcode
1 participant