Fork me on GitHub
#hoplon
<
2015-10-23
>
esp100:10:32

i started playing around with the html hlisp syntax, and it’s pretty cool. genius to reimagine html as a lisp! simple_smile

esp100:10:15

one question: is it possible to define elements (defelem) in an html.hl file?

esp100:10:35

i.e. use html syntax within the element definitions

micha00:10:47

it is, but you probably want to make some macros to help you out

micha00:10:34

the problem is when you want to use vectors or maps etc

micha00:10:00

what you want to do i think is to make html versions of defelem, your own macro

micha00:10:05

sort of like this maybe

micha00:10:54

things like that

micha00:10:05

you'd want to make html-let also, perhaps

micha00:10:28

an outline of what the macro would look like could be

micha00:10:08

the parse-e function is in hoplon/core.clj

micha00:10:26

it parses a hoplon sexp into [tag attr kids]

esp100:10:05

how to install the html-elem macro such that it is available in hlisp?

esp100:10:28

can it just be required in?

micha00:10:32

just make a file in your project, like suppose i was working on a project called "foop"

micha00:10:42

i'd have a source dir, "src"

micha00:10:58

and in there i'd make a clojure file src/foop/macros.clj perhaps

micha00:10:21

and in the foop.macros clojure namespace in that file i'd put my macro definitions

micha00:10:58

then in a cljs file i can do (:require-macros [foop.macros :refer [html-elem]])

micha00:10:02

or something like that

micha00:10:27

in the ns or page declaration, of course

micha00:10:37

like if you were making a hoplon page you'd do something like

micha00:10:00

(page "foo.html"
  (:require-macros [foop.macros :refer [html-elem]]))

esp100:10:16

ok so hlisp is just interpreting each tag as a function/macro in the current ns

micha00:10:57

we are now programming with lisp!

esp100:10:17

these macros seem pretty general purpose. would this be something to contribute back into hlisp for others to use?

micha00:10:32

yeah that would be awesome

micha00:10:55

also we might be able to modify the defelem macro to optionally accept the :args attribute

micha00:10:04

that would maybe be the ideal situation

micha00:10:25

but if you're not so familiar with macros you can make a separate one first

esp100:10:17

i’m ok w/macros; i tend to favor functions tho so i haven’t written a lot of them

micha00:10:43

yeah the macros hoplon has are just thin wrappers around functions

esp100:10:45

what your saying about defelem would allow using <defelem> directly in hlisp?

micha00:10:13

yeah you could then do (defelem :args [attr kids] (div ...))

micha00:10:33

in addition to (defelem [attr kids] (div ...))

micha00:10:51

the macro could dispatch on the type of the first form etc

micha00:10:09

if defelem accepted either syntax then it would work in html

micha00:10:51

(defelem :args [attr kids] ...) is same as <defelem args="{{ [attr kids] }}">...</defelem>

esp100:10:37

i’ll give it a shot and report back

micha00:10:59

awesome! 💇

alandipert00:10:25

updating the site tonight

micha00:10:25

very nice

micha00:10:58

i bet threadless can make a nice t shirt out of that

levitanong03:10:01

Awesome logo! :D

levitanong03:10:23

Oh by the way, is there any plan to add docstring support for defelem? I think that would be a great feature when working with big teams/big projects.

alandipert03:10:45

no plan, but a PR would be very welcome... it's a good idea

dm316:10:42

what's the current state of hoplon/boot/figwheel combo? Does it work well? Will have to try it myself anyway, I guess simple_smile maybe someone can point me into recent project examples?

raywillig20:10:57

how can i capture the value of innerHeight or innerWidth to a cell and and have it update when the browser window changes size?

alandipert20:10:47

@raywillig: (.on (js/jQuery js/window) "resize" (fn [e] ...)) and swap! your cells in that callback

raywillig20:10:19

oh awesome. thx @alandipert

raywillig21:10:59

@alandipert: that worked great. now my google map is always the right size

micha22:10:03

google map too small? one weird trick you didn't know about...