Skip to content
Snippets Groups Projects

Clarify how to use anchor links with ts

Merged homotechsual requested to merge github/fork/demeritcowboy/clarify-anchor-links into master

Created by: demeritcowboy

Anchor links are an exception to the general rule of avoiding tags within ts.

Also a note about how sometimes it's better to leave bad uses of ts as-is depending on the situation.

@mlutfy

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Created by: demeritcowboy

    Oh just had a thought - if there's a title attribute it probably should be within the ts body not the param. This is now extra confusing. Hmm.

  • Created by: mlutfy

    Looks good to me. Thank you @demeritcowboy !

    Regarding 'title' attributes, it should be pretty rare? Links embedded in text are usually descriptive enough, or should be.

    I will leave this open for docs folks to review.

  • Created by: demeritcowboy

    Good point - grepping shows title is common in general but not when the link is embedded in a bigger block of text. I've removed the title attribute from my examples to avoid confusion.

  • homotechsual
  • Good point - grepping shows title is common in general but not when the link is embedded in a bigger block of text. I've removed the title attribute from my examples to avoid confusion.

    I think it worth having an example of how to properly do a link title with ts to be frank.

  • homotechsual
  • Created by: demeritcowboy

    I think it worth having an example of how to properly do a link title with ts to be frank.

    I can add one. It might not be "proper", more like "defacto standard based on overwhelming existing usage".

  • homotechsual
  • homotechsual
  • homotechsual
  • Created by: demeritcowboy

    I updated. Hopefully clearer.

  • homotechsual
  • homotechsual
    homotechsual @homotechsual started a thread on commit cff03403
  • 102
    102
    103 An exception is `<a>` links which should be within the `ts`, but its parameters should be arguments to the ts. For example:
    104
    105 !!! failure "Bad"
    106
    107 ```smarty
    108 {ts}<a href="https://www.civicrm.org" target="_blank">CiviCRM Web Site</a>{/ts}
    109 ```
    110
    111 !!! success "Less bad"
    112
    113 ```smarty
    114 {ts 1='href="https://www.civicrm.org" target="_blank"'}<a %1>CiviCRM Web Site</a>{/ts}
    115 ```
    116
    • What do you think to a "multi-ts" example here?

      The scenario is this:

      I have a link - I need to translate the link text with ts. That link has title text which I also want to pass through ts - how can this be done "properly".

      I'm just thinking of what examples I've needed to lookup in the past here.

  • homotechsual
    homotechsual @homotechsual started a thread on commit cff03403
  • 102
    102
    103 An exception is `<a>` links which should be within the `ts`, but its parameters should be arguments to the ts. For example:
    104
    105 !!! failure "Bad"
    106
    107 ```smarty
    108 {ts}<a href="https://www.civicrm.org" target="_blank">CiviCRM Web Site</a>{/ts}
    109 ```
    110
    111 !!! success "Less bad"
    112
    113 ```smarty
    114 {ts 1='href="https://www.civicrm.org" target="_blank"'}<a %1>CiviCRM Web Site</a>{/ts}
    115 ```
    116
    • Created by: demeritcowboy

      I'm not sure if it's github's display or something wonky but the updated text clarifies (or tries to clarify) that there's a difference between links in larger blocks of text vs standalone links. The former rarely have title attributes because the block of text is the text.

  • Created by: demeritcowboy

    I'm going to separate this into 3 PR's. I'll leave this one with the original <a> link clarification with the suggested hyperlink wording applied. Another that's just about the title attributes which was initially confusing and obviously even after some revision is still a difficult topic because it's a bit of an oddball. And then the third which is about when to consider not changing things even if it's wrong.

  • Please register or sign in to reply
    Loading