Welcome to TalkGraphics.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2010
    Location
    Kildare, Ireland
    Posts
    906

    Default Text style class names in HTML

    Request for HTML publish to retain hyphens and underscores in custom text style names.

    For example; currently "my-style" publishes to HTML as class name "my-45style"

    and "my_style" publishes to HTML as class name "my-95style"

    It looks like it does this for all non-alphanumeric characters but hyphens and underscores are common in HTML class names so maybe they could export as-is?

    My use-case is to apply a custom class name eg. product-price-456789 to some text by using a text style name and then dynamically replace the text contained within the HTML span. I can put product-price-456789 as the actual text instead and replace it that way but being able to use the span class name would be nice.
    XT-CMS - a self-hosted CMS for Xara Designers - Xara + CMS Demo with blog & ecommerce shopping cart system.

  2. #2
    Join Date
    Apr 2012
    Location
    SW England
    Posts
    17,823

    Default Re: Text style class names in HTML

    Quote Originally Posted by xtom View Post
    Request for HTML publish to retain hyphens and underscores in custom text style names.
    For example; currently "my-style" publishes to HTML as class name "my-45style" and "my_style" publishes to HTML as class name "my-95style"
    It looks like it does this for all non-alphanumeric characters but hyphens and underscores are common in HTML class names so maybe they could export as-is?
    My use-case is to apply a custom class name eg. product-price-456789 to some text by using a text style name and then dynamically replace the text contained within the HTML span. I can put product-price-456789 as the actual text instead and replace it that way but being able to use the span class name would be nice.
    xtom, if it helps, change 'my_style' to 'my style' and the end-result is my_style - the space is changed to an underscore. A leading space returns x-_.

    Generally can you not work with Styles as Pascal case, 'ProductPrice 456789' or camelCase, 'productPrice 456789'? [ProductPrice_456789, productPrice_456789]

    The alternative would be to iterate through all class lists and replace the offending substitutions.

    Acorn
    Acorn - installed Xara software: Cloud+/Pro+ and most others back through time (to CC's Artworks). Contact for technical remediation/consultancy for your web designs.
    When we provide assistance, your responses are valuable as they benefit the community. TG Nuggets you might like. Report faults: Xara Cloud+/Pro+/Magix Legacy; Xara KB & Chat

  3. #3
    Join Date
    Apr 2010
    Location
    Kildare, Ireland
    Posts
    906

    Default Re: Text style class names in HTML

    Ah thanks Acorn, I did not try using a space, that is good to know.

    The naming convention I'm using for tags/class names is eg. cms-product-price-456789 , cms-page-content etc. any character can be upper or lower case but the words are separated with hyphens. I figured it was easiest to read no matter what case is used, although it does make them a bit longer.

    With your find I would have to add support to work with underscores too, which is doable. However I noticed afterwards that the class name is used twice, once in the span and again in a wrapping div, and it got a bit messier to pursue.

    I ended up adding find-and-replace support so any custom text or class name etc. can be set to be changed to whatever, much like your last suggestion. So in a theme config file you can set for example 'mystyle' => 'my-tag' or whatever and so it's stored and used automatically going forward. None of this was needed for standard placeholders with tags in the body but I was trying to get a bit more fine grain control over the text spans. ie. keep the text styling but just change the text and now this way allows for that too.
    XT-CMS - a self-hosted CMS for Xara Designers - Xara + CMS Demo with blog & ecommerce shopping cart system.

 

 

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •