Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Ruby Help - Outputting HTML

  1. #1
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default Ruby Help - Outputting HTML

    I'm learning Ruby
    Okay. To the point. I'm making a script that will repitively write out HTML tags...
    Like a for-loop. It serves no real purpose, but I'm trying to figure out how to do it.
    This is what I have
    Code:
    <% innertext = "Hello World!"
    tag = "<i>"+innertext+"</i>\n"
    max = 4
    print(innertext*max) %>
    It appears as normal text? Why won't it interpret the Ruby code?
    - Mike

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Why won't what interpret it? A PHP server setup wouldn't be expted to, an ASP server setup might try and fail.... Just not sure what you mean.
    Is this desktop based?
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    The browser is supposed to be able to interperet Ruby code with these tags:
    Code:
    <&#37; %>
    But unfortunately it doesn't work. I'm saving my html docs as .htm, and that may have something to do with it. Other than that, I'm pretty much in the dark.
    - Mike

  4. #4
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Judging from PHP, generally, I'd say be sure that .htaccess is configured to sent through ruby for whatever .ext's you want.
    I don't really know how it should work... can't say much more.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  5. #5
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    I think it has something to do with ASP files.. But again I'm not sure. Thanks anyways though.
    - Mike

  6. #6
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Not sure if it is related, but I read somewhere that ruby files need to have one of the following extensions:

    rb, rbx, or rhtml

    But then again, I'm not sure about this.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  7. #7
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    Hmm... rb, and rbx are for executable files (like exe, but it isn't. Well, sort of ) I'll try rhtml.
    - Mike

  8. #8
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    ASP may conflict, yes. It's the same open/close commands.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  9. #9
    Join Date
    Aug 2005
    Posts
    971
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    ruby?? HTML?? mburt do you mean rails? If so, then, I think you should change this:

    Code:
    <&#37; innertext = "Hello World!"
    tag = "<i>"+innertext+"</i>\n"
    max = 4
    print(innertext*max) %>
    to:

    Code:
    <% innertext = "Hello World!"
    tag = "<i>"+innertext+"</i>\n"
    max = 4
    print(tag*max) %>

  10. #10
    Join Date
    Jan 2007
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    You might also try changing your <&#37; %> tag to <%= %>. The extra equals sign means that you want the result of the block to be outputted as text. Without it, Ruby just assumes you're doing pure logic processing and aren't intending to output anything.

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
  •