Jump to content

Creation of custom JSON-T Formatters?

Recommended Posts

Hi!

I am running a Version 7.0 Template in Developer-Mode on trial. (Newbie alert 😉) Aiming on a dedicated template for a shop offering essential oils, is wish to design a template that takes a string and splits it at a designated character sequence (space+Pipe+space ` | `) .

Scenario;

{
  "item" : {
    "title" : "Mandarin r\u00F6d ekologisk | Citrus reticulata"
  }
}

Is it possible to define a regex-based function or a simpler string-split approach so that I can have different ways to represent the title depending on the output channel?

For example in the meta tags the pipe character is exactly the desired output and for the product name rendered on the product page the part which comes after the pipe should be rendered with a dedicated css class applied - perhaps also with semantic attributions marking it as the botanical name.

Dreaming big: Ideally a helper that invokes gomplate (or just a subset) would allow such freedom of controlling the output.

Any ideas how this can be done -- ideally without the need of having JavaScript altering the Output after-the-fact -- would be much appreciated. Thank you

Link to comment
  • Replies 1
  • Views 533
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.