sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Conventions for Output Code

    Scheduled Pinned Locked Moved Developers' Forum
    15 Posts 4 Posters 1.1k Views 4 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • M Offline
      MartinRinehart
      last edited by

      When writing Ruby that writes JavaScript, has anyone created a coding conventions guide for the output JavaScript?

      Example:
      a) Output code "<script type='text/JavaScript'>" should meet w3c valid code standards.
      b) Output code "<script>" runs in modern browsers. Anything more is a waste of bytes.

      Author, Edges to Rubies - The Complete SketchUp Tutorial at http://www.MartinRinehart.com/models/tutorial.

      1 Reply Last reply Reply Quote 0
      • thomthomT Offline
        thomthom
        last edited by

        Anything related to webdialogs I make by the W3C specs. (Unless I need to do some tweaks to work around IE bugs.)

        It's the safest thing to ensure that everything works on multiple platforms, and for future versions.

        Thomas Thomassen β€” SketchUp Monkey & Coding addict
        List of my plugins and link to the CookieWare fund

        1 Reply Last reply Reply Quote 0
        • M Offline
          MartinRinehart
          last edited by

          @thomthom said:

          Anything related to webdialogs I make by the W3C specs. (Unless I need to do some tweaks to work around IE bugs.)

          <br> or <br />?

          Warning: that is a trick question.

          Author, Edges to Rubies - The Complete SketchUp Tutorial at http://www.MartinRinehart.com/models/tutorial.

          1 Reply Last reply Reply Quote 0
          • Chris FullmerC Offline
            Chris Fullmer
            last edited by

            <br />

            Hows it a trick Q? All my books and W3 standards I've read suggest that it should only be <br /> as all tugs must have a closing />.

            Lately you've been tan, suspicious for the winter.
            All my Plugins I've written

            1 Reply Last reply Reply Quote 0
            • thomthomT Offline
              thomthom
              last edited by

              @chris fullmer said:

              <br />

              Hows it a trick Q? All my books and W3 standards I've read suggest that it should only be <br /> as all tugs must have a closing />.

              Only when you use XHTML. For plain vanilla HTML you shouldn't close it.

              I use XHTML as it allows simple XML parsers to traverse my documents and extract data.

              Thomas Thomassen β€” SketchUp Monkey & Coding addict
              List of my plugins and link to the CookieWare fund

              1 Reply Last reply Reply Quote 0
              • M Offline
                MartinRinehart
                last edited by

                @chris fullmer said:

                <br />

                Hows it a trick Q? All my books and W3 standards I've read suggest that it should only be <br /> as all tugs must have a closing />.

                The HTML 5 spec deprecates <br /> in favor of good old <br>. The silly version was born with, and dies with, XHTML, the one and only HTML that tried to be XML.

                Author, Edges to Rubies - The Complete SketchUp Tutorial at http://www.MartinRinehart.com/models/tutorial.

                1 Reply Last reply Reply Quote 0
                • GaieusG Offline
                  Gaieus
                  last edited by

                  C'mon guys, decide which one I should use. I build (rather amateur) websites but would like to work correctly.
                  πŸ˜‰

                  Gai...

                  1 Reply Last reply Reply Quote 0
                  • thomthomT Offline
                    thomthom
                    last edited by

                    @martinrinehart said:

                    @chris fullmer said:

                    <br />

                    Hows it a trick Q? All my books and W3 standards I've read suggest that it should only be <br /> as all tugs must have a closing />.

                    The HTML 5 spec deprecates <br /> in favor of good old <br>. The silly version was born with, and dies with, XHTML, the one and only HTML that tried to be XML.

                    HTML5 comes in XHTML flavour as well. So <br /> still lives if you opt in for the XML version.

                    Thomas Thomassen β€” SketchUp Monkey & Coding addict
                    List of my plugins and link to the CookieWare fund

                    1 Reply Last reply Reply Quote 0
                    • thomthomT Offline
                      thomthom
                      last edited by

                      @gaieus said:

                      C'mon guys, decide which one I should use. I build (rather amateur) websites but would like to work correctly.
                      πŸ˜‰

                      If you use HTML then don't close empty tags, if you use XHTML then you have to close empty tags.

                      Thomas Thomassen β€” SketchUp Monkey & Coding addict
                      List of my plugins and link to the CookieWare fund

                      1 Reply Last reply Reply Quote 0
                      • M Offline
                        MartinRinehart
                        last edited by

                        @gaieus said:

                        C'mon guys, decide which one I should use. I build (rather amateur) websites but would like to work correctly.
                        πŸ˜‰

                        All the major western browsers have been happy with <br> this century. If your doctype specifies "XHTML strict" you want "<br />". Otherwise the original is preferred.

                        According to Wikipedia, "HTML 5 is the next advancement of both HTML 4.01 and XHTML 1.0, as development on the next version of the latter has been ceased." (I think I'll go clean up that English.)

                        Author, Edges to Rubies - The Complete SketchUp Tutorial at http://www.MartinRinehart.com/models/tutorial.

                        1 Reply Last reply Reply Quote 0
                        • M Offline
                          MartinRinehart
                          last edited by

                          @thomthom said:

                          HTML5 comes in XHTML flavour as well. So <br /> still lives if you opt in for the XML version.

                          According to Wikipedia, "HTML 5 is the next advancement of both HTML 4.01 and XHTML 1.0, as development on the next version of the latter has stopped."

                          Author, Edges to Rubies - The Complete SketchUp Tutorial at http://www.MartinRinehart.com/models/tutorial.

                          1 Reply Last reply Reply Quote 0
                          • thomthomT Offline
                            thomthom
                            last edited by

                            Wiki isn't quite accurate. XHTML 1.0 was meant as a transition towards XML based documents. But IE put a fork in that. One of the reasons XHTML 2.0 died.

                            This sums up XHTML5 vs HTML5 nicely.
                            http://html5doctor.com/html-5-xml-xhtml-5/

                            HTML5 also gives some flex to <br/> style tags due to its widespread use: http://www.w3.org/TR/html-design-principles/#pave-the-cowpaths

                            Thomas Thomassen β€” SketchUp Monkey & Coding addict
                            List of my plugins and link to the CookieWare fund

                            1 Reply Last reply Reply Quote 0
                            • thomthomT Offline
                              thomthom
                              last edited by

                              One step forwards, two steps back, one step sideways shuffling forwards.

                              Thomas Thomassen β€” SketchUp Monkey & Coding addict
                              List of my plugins and link to the CookieWare fund

                              1 Reply Last reply Reply Quote 0
                              • M Offline
                                MartinRinehart
                                last edited by

                                @thomthom said:

                                This sums up XHTML5 vs HTML5 nicely.
                                http://html5doctor.com/html-5-xml-xhtml-5/

                                For better or worse, the WHATwg decided that XML was a mistake. The current w3c spec (August) is the original, XML-free WHATwg spec. Lawson is about 2 months earlier than the current w3c spec. An earlier version deprecated <br />. It's not even mentioned in the current spec. The formerly dead form, <br clear=...> has been resurrected as "deprecated but must be implemented as follows: ..."

                                @thomthom said:

                                HTML5 also gives some flex to <br/> style tags due to its widespread use: http://www.w3.org/TR/html-design-principles/#pave-the-cowpaths

                                Seems like good thinking, but much forgotten between '07 and today. I'll bet this is followed in practice even if it isn't in the spec. Can you imagine an actual browser shipped without supporting <center>?

                                But we wander. Back to my original question. I propose the following convention:

                                As browsers are more predictable in standards mode than quirks mode, Ruby-generated HTML should include a doctype and should be valid for its doctype.

                                Author, Edges to Rubies - The Complete SketchUp Tutorial at http://www.MartinRinehart.com/models/tutorial.

                                1 Reply Last reply Reply Quote 0
                                • thomthomT Offline
                                  thomthom
                                  last edited by

                                  hm.. that's interesting. Haven't paid much attention to HTML5 the last few months.

                                  @martinrinehart said:

                                  But we wander. Back to my original question..

                                  Ah, yea. The topic! πŸ˜„ Sorry, I often stray away and webdev is one of my major interests so I stray even quicker and further when that topic is even remotely related. 😳

                                  @martinrinehart said:

                                  As browsers are more predictable in standards mode than quirks mode, Ruby-generated HTML should include a doctype and should be valid for its doctype.

                                  Agree. Since webdialogs must run under the webkit engine and IE the best chance for platform compatibility is following the W3C standards.

                                  When I make webdialogs I do the same as I do when I develop websites. I code to the standards, then to account for IE notoriously bad handling of the standards I add some conditional comments that adds CSS and JS fixes. Most of the time visual quirks in IE is by triggering hasLayout

                                  For better legibility and re-usability, separate CSS and JS their own respective files.

                                  Using HTML validators to detect correct markup is very important. Once a document is invalid there's no way to predict how the different rendering engines will recover and you can not expect cross platform compatibility.

                                  I'm starting to realise that there hasn't been posted any recommendations of best practices when it comes to webdialogs. Coming from a webdesign background I haven't given it much thought.

                                  Thomas Thomassen β€” SketchUp Monkey & Coding addict
                                  List of my plugins and link to the CookieWare fund

                                  1 Reply Last reply Reply Quote 0
                                  • 1 / 1
                                  • First post
                                    Last post
                                  Buy SketchPlus
                                  Buy SUbD
                                  Buy WrapR
                                  Buy eBook
                                  Buy Modelur
                                  Buy Vertex Tools
                                  Buy SketchCuisine
                                  Buy FormFonts

                                  Advertisement