Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Suggestion]How about simplify and unify the elements style/format ? #20

Open
touchft opened this issue Apr 13, 2021 · 1 comment
Open

Comments

@touchft
Copy link

touchft commented Apr 13, 2021

If all elements keep the same syntax style/format, it will be simple and easy to learn and use.

Let's take a look at the NORMAL_ELEMENTS from the module Genie.Renderer.Html

Basic HTML Element style

<tag attr_1="xxx" attr_2 attr_3="yyy">content</tag>

The above html element style can be translate to NORMAL_ELEMENTS as the following (take h1 as example of tag, which may not express the true meaning)

julia> h1("content",attr_1="xxx", attr_2="", attr_3="yyy")
"<h1 attr_1=\"xxx\" attr_2 attr_3=\"yyy\">content</h1>"

or

julia> h1(attr_1="xxx", attr_2="", attr_3="yyy", ["content"])
"<h1 attr_1=\"xxx\" attr_2 attr_3=\"yyy\">content</h1>"

That's fine from HTML to Julia. Let's look at something from Julia to HTML

julia> h1(attr_1="xxx", :attr_2, attr_3="yyy", ["content"])
"<h1 attr_1=\"xxx\" attr_3=\"yyy\" [\"content\"]>attr_2</h1>"

julia> h1(:a=>1)
"<h1>:a => 1</h1>"

julia> h1([:a=>1,:b=>2])
"<h1>[:a => 1, :b => 2]</h1>"

Obviously, the above julia style CANNOT translate to correct HTML format as we want.

If keeping style as simple as possible is the first important thing, the less julia function style for NORMAL_ELEMENTS is better. And same rule is suggested for elements in StippleUI.

@hhaensel
Copy link
Member

We modified the API quite a bit, although we didn't document it well yet.

Unless there anren't any named positional arguments the API is as follows:

  • the first positional argument goes in the inner part
  • any argument that is an array now goes in the inner part.
  • all other positional arguments are passed as parameters
  • all keyword arguments are passed as parameters, Symbols as values indicate binding to a model field or expression
  • symbols are passed as boolean parameters with the value true

That gives quite some flexibility in arranging the arguments in a well readable form.

julia> quasar(:api__demo, "a", "b", "c", :d, :e, :f, x = 1, y = :y0, [" demo text"])
"<q-api-demo :y=\"y0\" x=1 b c d e f>a demo text</q-api-demo>"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants