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

Not an issue, just a question #1

Open
cdmojoli opened this issue Jan 3, 2023 · 2 comments
Open

Not an issue, just a question #1

cdmojoli opened this issue Jan 3, 2023 · 2 comments

Comments

@cdmojoli
Copy link

cdmojoli commented Jan 3, 2023

Why not use symbols instead of keywords, to reduce syntax? Hiccup and others also go with keywords. Is it performance or memory footprint?

E.g.
(jack-html `(div/id1.c1 (h1 (p ,text))))

@tonyaldon
Copy link
Owner

In jack we could have use symbols instead of keywords.

There would be almost no difference in the implementation:

  • Two small changes in jack-parse-tag-kw in order not to check for
    keywords and a match that doesn't take into account the : starting a
    keyword (seen as a string),
  • use symbolp instead of keywordp in jack-html.

I chose keywords over symbols because I find it more readable since
keywords are highlighted and not symbols. This gives you something
similar as in html-mode where tags are highlighted. So this has
nothing to do with performance neither memory footprint.

If we talk about Hiccup (Clojure), you do not have to use keywords.
Symbols and strings are also accepted:

user=> (use 'hiccup.core)
nil
user=> (html ['div#id1.c1 ['h1 ['p "text"]]])
"<div class=\"c1\" id=\"id1\"><h1><p>text</p></h1></div>"
user=> (html [:div#id1.c1 [:h1 [:p "text"]]])
"<div class=\"c1\" id=\"id1\"><h1><p>text</p></h1></div>"
user=> (html ["div#id1.c1" ["h1" ["p" "text"]]])
"<div class=\"c1\" id=\"id1\"><h1><p>text</p></h1></div>"

I hope this answer your question.

@cdmojoli
Copy link
Author

cdmojoli commented Jan 5, 2023

Thanks for providing the insight, I did not expect the highliting aspect (which makes a lot of sense). Neither did I know one could use symbols in Hiccup.

I have been uncommittedly fantasizing about an "any-lisp anytime" HTML generation strategy that works in elisp, Clojure, CL and Scheme. One could get immediate results within Emacs, and deploy to other lispy languages (bootstrapping and surrounding app logic would be lispy-variant-specific); at development time or runtime, server side or client side (e.g. ClojureScript).

Perhaps that may someday lead to an abstraction where a view is described by its generation template, but the time&place of generation is left as an optimization which decides which bits are SSG, SSR or CSR.

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