Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • libhtml available on SSC

    Thanks again to KitBaum for making another package available via the SSC archives. The libhtml package installs an ado wrapper that is used to download and compile Mata class definitions for HTML5 elements; you can view the source for the classes at https://github.com/wbuchanan/matahtml. Each class includes methods that correspond to the parameters available to the individual elements and a single method is implemented by all classes to insert content into the element. For example to create the an HTML tag like:

    <a href="www.somewebsite.com">this is the content for the HTML element 'a'</a>

    You would use:

    Code:
    : a = a()
    
    : a.setHref("www.somewebsite.com").setClassArgs("this is the content for the HTML element 'a'").print()
      \x0a<a href="www.somewebsite.com">this is the content for the HTML element 'a'</a>\x0a
    All the classes implement a "fluent" style interface (e.g., can chain method calls on an object) and use a .print() method to finalize and print the object into an HTML document. Each of the parameters allowed by a given element can be set using setter methods like .setHref() above and if you wanted to extract only a specific parameter value from an element, there are similarly named getter methods:

    Code:
    : a.getHref()
       href="www.somewebsite.com"
    Because of the number of classes (and my attempt to make it easier to maintain the classes and/or find bugs in them) the source isn't installed directly, but calling libhtml initially will install the source in `"`c(sysdir_plus)'h/"' and then will compile the source into a Mata library for you.
Working...
X