diff --git a/NEWS.md b/NEWS.md index 6986c0b..a2a3cc6 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,11 @@ # Release Notes +## v0.9.3 + +- Pull #18: Interpolating within a paired tags +- Pull #19: Fix bug where
throws error +- Pull #20: Interpolating within self-closing tag + ## v0.9.2 - Fix #17: Attribute interpolation bug diff --git a/Project.toml b/Project.toml index f3eab61..2565460 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "HypertextLiteral" uuid = "ac1192a8-f4b3-4bfe-ba22-af5b92cd3ab2" authors = ["Clark C. Evans "] -version = "0.9.2" +version = "0.9.3" [compat] julia = "1" diff --git a/docs/src/attribute.md b/docs/src/attribute.md index 5c51643..7a9072f 100644 --- a/docs/src/attribute.md +++ b/docs/src/attribute.md @@ -202,94 +202,6 @@ of CSS classes and a custom style. print(@htl "
Hello
") #->
Hello
-## Tag name interpolation - -To dynamically set the tag name, you put the interpolation right where -you would normally put the tag name. - - tagname = "div" - @htl """<$tagname class=active>""" - #->
- - tagname = "htl-code-block" - @htl """<$tagname class=active>""" - #-> - - tagname = "my-web-component" - @htl """<$tagname/>""" - #-> - - tagname = "open-file" - @htl """""" - #-> - -In case of custom components, you might want to extend the tagname. -This also is possible. - - tagname = "code" - @htl """import HypertextLiteral""" - #-> import HypertextLiteral - - prefix = "htl" - @htl """<$prefix-code class=julia>import HypertextLiteral""" - #-> import HypertextLiteral - -Because with tags there isn't much fancy interpolation work we can do, -you can't put in any complex object. - - complex_prefix = Dict(:class => :julia) - @htl """<$complex_prefix>import HypertextLiteral""" - #-> ERROR: "Can't use complex objects as tag name" - -A tag name _can_ be very flexible, in Chrome `` is a valid tag name. -Stricly, only the first character has to be `/[a-z]/i`, -and the rest can be anything but `/`, `>` and ` ` (space). -(Yes, theoretically, you can have a `<` in your tag name). - - contains_space = "import HypertextLiteral" - @htl """<$contains_space>""" - #-> ERROR: "Content within a tag name can only contain latin letters, numbers or hyphens (`-`)" - - contains_bigger_than = "a
" - @htl """<$contains_bigger_than>""" - #-> ERROR: "Content within a tag name can only contain latin letters, numbers or hyphens (`-`)" - - contains_slash = "files/extra.js" - @htl """<$contains_slash>""" - #-> ERROR: "Content within a tag name can only contain latin letters, numbers or hyphens (`-`)" - - starts_with_hyphen = "-secret-tag-name" - @htl """<$starts_with_hyphen>""" - #-> ERROR: "A tag name can only start with letters, not `-`" - - empty = "" - @htl """<$empty>""" - #-> ERROR: "A tag name can not be empty" - - empty = "" - @htl """<$empty/>""" - #-> ERROR: "A tag name can not be empty" - -But I figured, better safe than sorry, let's only allow characters people commonly use. -(We can always make this less restrictive, but making it more restrictive would be a breaking change) -Also, until someone finds it necessary to implement this, we treat tags with a prefix as -tag names, thus requiring it to be non-empty and not start with a hyphen. - - technically_valid_but_weird = "Technically⨝ValidTag™" - @htl """<$technically_valid_but_weird>""" - #-> ERROR: "Content within a tag name can only contain latin letters, numbers or hyphens (`-`)" - - @htl """<$technically_valid_but_weird/>""" - #-> ERROR: "Content within a tag name can only contain latin letters, numbers or hyphens (`-`)" - - technically_valid_starts_with_hyphen = "-secret-tag-name" - @htl """""" - #-> ERROR: "A tag name can only start with letters, not `-`" - - technically_valid_empty = "" - @htl """""" - #-> ERROR: "A tag name can not be empty" - ## Style Tag Within a `