Coder Social home page Coder Social logo

hiccup.jl's Introduction

Hiccup

Pkg.add("Hiccup")

Hiccup.jl is a super-simple library designed to make making HTML easy in Julia. It's heavily inspired by Clojure's Hiccup DSL.

julia> using Hiccup

julia> Hiccup.div("#foo.bar", "hi")
<div class="bar" id="foo">hi</div>

HTML nodes are stored as the Node{T} type which renders itself smartly.

julia> Node(:img, "#id.class1.class2", Dict(:src=>"http://www.com"))
<img src="http://www.com" id="id" class="class1 class2" />

julia> tag(ans)
:img

A bunch of utility functions, with the names of tags, are provided which make this a bit more legible. You can import more with @tags:

julia> @tags img, svg

julia> svg("#id.class1.class2", Dict(:src=>"http://www.com"))
<svg class="class1 class2" src="http://www.com" id="id"></svg>

And that's basically it.

hiccup.jl's People

Contributors

ajkeller34 avatar femtocleaner[bot] avatar jgoldfar avatar jiahao avatar juliatagbot avatar maximsch2 avatar mikeinnes avatar pfitzseb avatar ranjanan avatar rdeits avatar ssfrr avatar tkelman avatar totalverb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

hiccup.jl's Issues

Broken on 0.6

I'm getting

julia> Pkg.test("Hiccup")
INFO: Computing test dependencies for Hiccup...
INFO: No packages to install, update or remove
INFO: Testing Hiccup
ERROR: LoadError: LoadError: function reduce does not accept keyword arguments
Stacktrace:ERROR (unhandled task failure): ArgumentError: Module Revise not found in current path.
Run `Pkg.add("Revise")` to install the Revise package.
Stacktrace:
 [1] _require(::Symbol) at ./loading.jl:435
 [2] require(::Symbol) at ./loading.jl:405
 [3] macro expansion at /Users/twan/.juliarc.jl:3 [inlined]
 [4] (::##1#2)() at ./task.jl:335

 [1] include_from_node1(::String) at ./loading.jl:576
while loading /Users/twan/code/julia/blinktest/v0.6/Hiccup/src/Hiccup.jl, in expression starting on line 67
while loading /Users/twan/code/julia/blinktest/v0.6/Hiccup/test/runtests.jl, in expression starting on line 1

on Julia 0.6.4 with Hiccup 0.1.1.

Tag a new version?

The last released version doesn't work on the nightly. It would be nice to just put a new tag on this.

adding attributes containing dashes

Hello. This looks like a useful utility for those generating HTML server-side. I need to be able to create attributes that contain a dash in them, such as the following. Currently, this is super inconvenient. I'm wondering might be a good alternative?

julia> button(Dict(Symbol("hx-post")=>"/clicked",Symbol("hx-swap")=>"outerHTML"), "Click Me")
<button hx-swap="outerHTML" hx-post="/clicked">Click Me</button>

Precompilation broken on master

The failure is on the exporttags line (Hiccup.jl:123)

julia> using Hiccup

WARNING: deprecated syntax "type" at /home/viralbshah/.julia/v0.7/Hiccup/src/Hiccup.jl:18.
Use "mutable struct" instead.

WARNING: deprecated syntax "parametric method syntax tag{T}(node::Node{T}) around /home/viralbshah/.julia/v0.7/Hiccup/src/Hiccup.jl:23".
Use "tag(node::Node{T}) where T" instead.
ERROR: LoadError: AssertionError: isexpr(ts, :tuple)
Stacktrace:
 [1] include_relative(::Module, ::String) at ./loading.jl:464
 [2] _require(::Symbol) at ./loading.jl:401
 [3] require(::Symbol) at ./loading.jl:318
while loading /home/viralbshah/.julia/v0.7/Hiccup/src/Hiccup.jl, in expression starting on line 123

Hiccup.div conflicts with Base.div

div is an export of Hiccup.jl, but is also a part of Base. In newer versions of Julia this export is not useful because it is shadowed by Base.div, and the result is that neither Base.div nor Hiccup.div can be used unqualified. Probably the best solution is to export div under a different name.

Nested divs with id errorv

Hiccup could not provide wrigth nested divs.
sorry by html output...

Ex:
julia> div("#outer",div("#medium", div("#inner")))
"div id="outer" >div id="medium" >div>#inner /div>/div>/div>"

julia> div("#outer",div("#medium", div("#inner","")))
"div id="outer">div id="medium">div id="inner">/div>/div>/div>"

Generating a script tag containing JavaScript code

I tried to generate a script tag that contains a JavaScript code like this:

<script type="text/javascript">
console.log(1);
</script>

However, I couldn't find a way because script doesn't work as I expected when it takes a Dict argument:

julia> using Hiccup

julia> @tags script
script (generic function with 1 method)

julia> script("console.log(1);")
<script>console.log(1);</script>

julia> script("console.log(1);", Dict(:type=>"text/javascript"))
<script type="text/javascript" class="log"></script>

Is this an intended behavior or a bug?

Deprecate exported tags?

It seems to me that it's a lot more flexible for a package to simply declare the @tags that it uses than to have Hiccup export a fixed list of them. Thoughts?

Tag new release?

On v0.5, tests don't pass, but on master it does. Could you tag a new release please?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.