a XiMpLe update

meik michalke meik.michalke at uni-duesseldorf.de
Thu Dec 22 12:01:52 GMT 2022


hi,

Am Montag, 28. November 2022, 15:41:20 CET schrieb meik michalke:
> i've also tried to make the XML parser not freak out when it encounters
> empty attributes (i.e., only the attribute name without a value, as common
> in HTML5). that needs more testing. the current workaround is to add a
> value (same as attribute name), as there's still no way to generate empty
> attributes yet.

i have now also fixed this long standing issue. now you can not only parse, 
but also generate empty attributes, by setting an attribute's value to 
character():

  gen_tag_functions(
    tags=c("input"),
    envir=as.environment("XiMpLe_wrappers")
  )
  input_(type="checkbox", checked=character(), disabled=character())
  # <input type="checkbox" checked disabled />

with the latest additions, XiMpLe can pretty much also be used to comfortably 
maintain static HTML web projects. instead of templating, you write functions 
that generate pages. i've also included a new function to deal with static 
files (like CSS, JavaScript or web fonts) called provide_file(). here's an 
example from ?provide_file:

  my_HTML <- XMLNode(
    "link",
    rel="stylesheet",
    type="text/css",
    href=provide_file(
      rel="static/css/bootstrap.min.css",
      to="/tmp",
      from="~/webpage/v1"
    )
  )

this would generate a <link> tag:

  # <link rel="stylesheet" type="text/css" href="static/css/bootstrap.min.css"
  # />

but instead of simply setting the href attribute, provide_file() looks for an 
actual copy of that file at ~/webpage/v1/static/css/bootstrap.min.css and 
writes a copy to the web project root, here /tmp/static/css/bootstrap.min.css.
this can also be used for images etc. it ensures that all referenced files are 
actually available, and you can always regenerate a complete, working web 
project from scratch. e.g., you can quickly examine what the complete web page 
would look like with a different theme, behave with an updated bootstrap 
version etc.

i have already realized a small web project using the package (it was actually 
the driving force behind my recent work on XiMpLe) and am preparing to replace 
the old PHP code of two much more complex pages in the near future with static 
HTML this way.

i have also prepared rkwarddev to work with the new version. most work here 
was getting the unit tests to run again because the new object class layout 
had slightly changed. i finally decided to keep the old classes in the package 
(otherwise it wouldn't have been possible to load saved objects that were 
generated by older versions of XiMpLe) and added methods as_XiMpLe_node() and 
as_XiMpLe_doc() to update these old objects.

in case you'd like to check it out:

  devtools::install_github("rkward-community/XiMpLe", ref="develop")

i'm planning to upload this to CRAN shortly, so if you run into issues, please 
drop me a note :)


viele grüße :: m.eik

-- 
  dipl. psych. meik michalke
  institut f"ur experimentelle psychologie
  abt. f"ur diagnostik und differentielle psychologie
  heinrich-heine-universit"at d-40204 d"usseldorf
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/rkward-devel/attachments/20221222/0d991283/attachment.sig>


More information about the rkward-devel mailing list