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

Generating a script tag containing JavaScript code #18

Open
bicycle1885 opened this issue Oct 13, 2016 · 2 comments
Open

Generating a script tag containing JavaScript code #18

bicycle1885 opened this issue Oct 13, 2016 · 2 comments

Comments

@bicycle1885
Copy link

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?

@MikeInnes
Copy link
Member

The first (string) argument is interpreted as a class name; you should be able to replace that with an empty string and put the contents after the dict to get the intended behaviour.

I'll be the first to say that this behaviour is pretty confusing – so we're looking to overhaul the api in future.

@bicycle1885
Copy link
Author

Thank you. I'll use raw HTML strings for a while.

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