Daniel Does
Daniel Does

Reputation: 58

When styling a Tumblr theme, is {TagsAsClasses} truly the best way to style posts differently, based on what tags it has?

A developer here says it could mess up the intended styling if someone chose to tag your post with something else. the workaround that they gave seems unnecessarily complicated. Do you agree with this person's point of view? Is there anything else you might suggest?

Upvotes: 2

Views: 780

Answers (1)

mikedidthis
mikedidthis

Reputation: 4897

Styling with Tags

Sadly the documentation for TagsAsClasses is a little incomplete, but clarified here:

If you’re using {TagsAsClasses} to apply special formatting to posts with certain tags, you might not want those particular tags showing up on your blog or on the Dashboard. Luckily, tags prefixed with an underscore, like _promo, will only appear in {TagsAsClasses} (with the underscore removed).

This can still cause issues as the prefix _ is removed on render, _promo becomes promo. If the user tags a post promo it will unintentionally invoke the style.

Double Up!

The simplest solution would be to double prefix any tags used for styling purposes. __promo becomes _promo. You can then style ._promo as you see fit.

Upvotes: 3

Related Questions