What is the difference between the two following pieces of c

Discussion in 'Ruby' started by Doney Kaka, Nov 17, 2009.

  1. Doney Kaka

    Doney Kaka Guest

    Doney Kaka, Nov 17, 2009
    #1
    1. Advertising

  2. Chris Mowforth, Nov 17, 2009
    #2
    1. Advertising

  3. Doney Kaka wrote:
    > Don't really know where to go with this one, but I gotta know...
    > What is the difference between the two following pieces of code?
    > Code:
    > <%= h(truncate(product.description, 80)) %>
    > and
    > Code:
    > <%= truncate(product.description, 80) %>


    Ruby is not Rails, and Rails questions are best asked on a Rails mailing
    list.

    But briefly: Rails defines a helper method escapeHTML() with alias h().
    This escapes HTML, so for example if the product.description is "a<b" it
    turns it into "a&lt;b". This is important to prevent users injecting
    their own tags and code into the page, as well as ensuring the page
    renders properly.
    --
    Posted via http://www.ruby-forum.com/.
    Brian Candler, Nov 17, 2009
    #3
  4. Re: What is the difference between the two following pieces

    > Ruby is not Rails, and Rails questions are best asked on a Rails mailing
    > list.


    I was about to say the same thing but remembered this method can be
    found in the standard library. Although in reality I guess rails is the
    only context it'll be used in...
    --
    Posted via http://www.ruby-forum.com/.
    Chris Mowforth, Nov 17, 2009
    #4
  5. Re: What is the difference between the two following pieces

    Chris Mowforth wrote:
    >> Ruby is not Rails, and Rails questions are best asked on a Rails mailing
    >> list.

    >
    > I was about to say the same thing but remembered this method can be
    > found in the standard library. Although in reality I guess rails is the
    > only context it'll be used in...


    Well, Rails is not the only Web framework for Ruby, and anyway, HTML
    escaping would be useful in CGI scripts and parsers...

    Best,
    --
    Marnen Laibow-Koser
    http://www.marnen.org

    --
    Posted via http://www.ruby-forum.com/.
    Marnen Laibow-Koser, Nov 18, 2009
    #5
  6. Re: What is the difference between the two following pieces

    Marnen Laibow-Koser wrote:
    > Chris Mowforth wrote:
    >>> Ruby is not Rails, and Rails questions are best asked on a Rails mailing
    >>> list.

    >>
    >> I was about to say the same thing but remembered this method can be
    >> found in the standard library. Although in reality I guess rails is the
    >> only context it'll be used in...

    >
    > Well, Rails is not the only Web framework for Ruby, and anyway, HTML
    > escaping would be useful in CGI scripts and parsers...
    >
    > Best,
    > --
    > Marnen Laibow-Koser
    > http://www.marnen.org
    >


    Totally, but let's not start debating that. #candlerb implied that this
    was an RoR thing and the question should be posted elsewhere; he should
    RTFM.
    --
    Posted via http://www.ruby-forum.com/.
    Chris Mowforth, Nov 18, 2009
    #6
  7. Re: What is the difference between the two following pieces

    Chris Mowforth wrote:
    > Marnen Laibow-Koser wrote:
    >> Chris Mowforth wrote:
    >>>> Ruby is not Rails, and Rails questions are best asked on a Rails mailing
    >>>> list.
    >>>
    >>> I was about to say the same thing but remembered this method can be
    >>> found in the standard library. Although in reality I guess rails is the
    >>> only context it'll be used in...

    >>
    >> Well, Rails is not the only Web framework for Ruby, and anyway, HTML
    >> escaping would be useful in CGI scripts and parsers...
    >>
    >> Best,
    >> --
    >> Marnen Laibow-Koser
    >> http://www.marnen.org
    >>

    >
    > Totally, but let's not start debating that. #candlerb implied that this
    > was an RoR thing and the question should be posted elsewhere; he should
    > RTFM.


    When you make incorrect statements (like "this will only be used in
    Rails"), it's a little funny to tell others to RTFM.


    Best,
    --
    Marnen Laibow-Koser
    http://www.marnen.org

    --
    Posted via http://www.ruby-forum.com/.
    Marnen Laibow-Koser, Nov 18, 2009
    #7
  8. Re: What is the difference between the two following pieces

    > When you make incorrect statements (like "this will only be used in
    > Rails"), it's a little funny to tell others to RTFM.
    >
    >
    > Best,
    > --
    > Marnen Laibow-Koser
    > http://www.marnen.org
    >



    When did I ever explicitly say that? And honestly, who the **** uses it
    in anything else? I think it's a fair assertion. Enough with the
    pedantry, I'm not replying to this any more. Composers obviously have
    the time to pursue these things.
    --
    Posted via http://www.ruby-forum.com/.
    Chris Mowforth, Nov 18, 2009
    #8
  9. Re: What is the difference between the two following pieces

    Chris Mowforth wrote:
    >> When you make incorrect statements (like "this will only be used in
    >> Rails"), it's a little funny to tell others to RTFM.
    >>
    >>
    >> Best,
    >> --
    >> Marnen Laibow-Koser
    >> http://www.marnen.org
    >>

    >
    >
    > When did I ever explicitly say that?


    You said it quite explicitly in
    http://www.ruby-forum.com/topic/199335#868114 : "Although in reality I
    guess rails is the only context it'll be used in..."

    > And honestly, who the **** uses it
    > in anything else?


    Anybody dealing with HTML without Rails. Presumably, that includes the
    sizable Merb community, among others.

    > I think it's a fair assertion.


    It might be if Rails were the only popular Ruby Web framework. But
    that's not actually the case.

    > Enough with the
    > pedantry, I'm not replying to this any more.


    Probably a good idea.

    > Composers obviously have
    > the time to pursue these things.


    Best,
    --
    Marnen Laibow-Koser
    http://www.marnen.org

    --
    Posted via http://www.ruby-forum.com/.
    Marnen Laibow-Koser, Nov 19, 2009
    #9
  10. Doney Kaka

    Josh Cheek Guest

    Re: What is the difference between the two following pieces

    [Note: parts of this message were removed to make it a legal post.]

    Also, http://ruby-toolbox.com/categories/web_app_frameworks.html lists 6
    other Ruby web frameworks. And there are certainly non web application uses
    for HTML as well.
    Josh Cheek, Nov 19, 2009
    #10
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. jakk
    Replies:
    4
    Views:
    12,039
  2. Jay
    Replies:
    11
    Views:
    679
    Nick Landsberg
    Feb 25, 2004
  3. pap74
    Replies:
    0
    Views:
    990
    pap74
    Jul 7, 2009
  4. marwie
    Replies:
    16
    Views:
    367
    Jonathan Gardner
    Feb 22, 2010
  5. iMath
    Replies:
    5
    Views:
    245
    Piet van Oostrum
    Sep 9, 2012
Loading...

Share This Page