Extra spaces in {linkText} #99

Closed
RicardoNunoSilva opened this Issue May 8, 2012 · 4 comments

Comments

Projects
None yet
2 participants
@RicardoNunoSilva

About the new {linkText} option in Template, I've been noticing it sometimes includes annoying leading blank spaces.

Example: I have a template like this:
{linkText}
{url}

In this page http://www.flickr.com/photos/artour_a/5211327406/
there are some links in the sidebar to the right.
Try to use the above Template to copy the link "Caterpillars of the world", and it will give you this:

                                    Caterpillars of the world
                (Álbum: 104)

http://www.flickr.com/photos/artour_a/sets/72157627461869613/with/5211327406/

I was hoping for something like:

Caterpillars of the world
(Álbum: 104)
http://www.flickr.com/photos/artour_a/sets/72157627461869613/with/5211327406/

or

Caterpillars of the world (Álbum: 104)
http://www.flickr.com/photos/artour_a/sets/72157627461869613/with/5211327406/

You may want to check this :)
Maybe you can trim all leading spaces (ie. in the start of the string)?
Thanks.

@neocotic

This comment has been minimized.

Show comment
Hide comment
@neocotic

neocotic May 8, 2012

Member

Instead of always trimming linkText I'd prefer to provide a set of string manipulation operations that can be used in conjunction with any other variables etc. I'm surprised I haven't done this sooner.

Operations (I'm using underscores (_) in the examples to represent spaces):

  • trim
    • "__foo__" -> "foo"
  • trimLeft
    • "__foo__" -> "foo__"
  • trimRight
    • "__foo__" -> "__foo"
  • upperCase
    • "foo" -> "FOO"
  • lowerCase
    • "FOO" -> "foo"
  • length
    • "foo" -> 3
    • Not sure how useful this will be
  • capitalize/capitalise
    • "foo_bar" -> "Foo_Bar"
  • tidy
    • "__foo___bar__" -> "_foo_bar_"
    • replace(/([ \t]+)/g, ' ')
    • This will reduce all spaces and tabs into a single space

Using tidy should achieve what you're looking for;

{#tidy}{linkText}{/tidy}

What do you think?

Member

neocotic commented May 8, 2012

Instead of always trimming linkText I'd prefer to provide a set of string manipulation operations that can be used in conjunction with any other variables etc. I'm surprised I haven't done this sooner.

Operations (I'm using underscores (_) in the examples to represent spaces):

  • trim
    • "__foo__" -> "foo"
  • trimLeft
    • "__foo__" -> "foo__"
  • trimRight
    • "__foo__" -> "__foo"
  • upperCase
    • "foo" -> "FOO"
  • lowerCase
    • "FOO" -> "foo"
  • length
    • "foo" -> 3
    • Not sure how useful this will be
  • capitalize/capitalise
    • "foo_bar" -> "Foo_Bar"
  • tidy
    • "__foo___bar__" -> "_foo_bar_"
    • replace(/([ \t]+)/g, ' ')
    • This will reduce all spaces and tabs into a single space

Using tidy should achieve what you're looking for;

{#tidy}{linkText}{/tidy}

What do you think?

@RicardoNunoSilva

This comment has been minimized.

Show comment
Hide comment
@RicardoNunoSilva

RicardoNunoSilva May 8, 2012

Enabling the use of "string operators" on your Template extension seems a great idea to me.
It offers more flexibility and post-processing control for end-users, while maintaining simplicity.

Enabling the use of "string operators" on your Template extension seems a great idea to me.
It offers more flexibility and post-processing control for end-users, while maintaining simplicity.

@neocotic

This comment has been minimized.

Show comment
Hide comment
@neocotic

neocotic May 8, 2012

Member

I still need to work out a workaround/fix for #97 before I can add any changes as it's preventing any additions to Template. I'll concentrate on that now and then I'll get to work on this. I might change tidy so that the result is also trimmed, removing the need to wrap {tidy} in {trim}.

Member

neocotic commented May 8, 2012

I still need to work out a workaround/fix for #97 before I can add any changes as it's preventing any additions to Template. I'll concentrate on that now and then I'll get to work on this. I might change tidy so that the result is also trimmed, removing the need to wrap {tidy} in {trim}.

@neocotic

This comment has been minimized.

Show comment
Hide comment
@neocotic

neocotic May 9, 2012

Member

This is now live in development and I'm happy with the results of testing after fixing a few bugs so I'll be including this in an update later today.

Member

neocotic commented May 9, 2012

This is now live in development and I'm happy with the results of testing after fixing a few bugs so I'll be including this in an update later today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment