Internal Tag Parsing in Ghost

Viewed 326

Within ghost if I use the following to display all internal tags,

{{#get "tags" limit="all"}}
    {{#foreach tags visibility="internal"}}
        {{name}}
    {{/foreach}}
{{/get}}

How do I display a tag that has a certain string and then string off the beginning. i.e I want to add an internal tag of: #META:Cisco / ASA / 8.2.1 But to print Cisco / ASA / 8.2.1 only

1 Answers

Nice question. :)

Unfortunately, I don't think you can do this simply using the built-in features, but you can create a custom app that registers a custom helper that can do this. Here's how to do that:

  1. Install the ghost-app package to your Ghost installation
  2. Check out the docs on how to create an app.
  3. Create the app. :)
  4. Modify gscan to recognize your helper.

Since I found your question interesting, I implemented this app myself. You can view and download the source code from here: https://github.com/conwid/RemovesubstringApp

I also wrote a little blog post about how I created it and how you can set it up and modify gscan in detail here: https://dotnetfalcon.com/stackoverflow-adventures-creating-custom-ghost-helpers-using-apps/

With my version, you'll be able to write this in your templates:

{{#get "tags" limit="all"}}
    {{#foreach tags visibility="internal"}}
        {{removeSubstring name '#META:'}}
    {{/foreach}}
{{/get}}

Hope this helps, if you have problems with the implementation or the setup, feel free to ask.

Related