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

compile time exception with script content #30

Closed
pbrisbin opened this issue Dec 21, 2011 · 7 comments
Closed

compile time exception with script content #30

pbrisbin opened this issue Dec 21, 2011 · 7 comments

Comments

@pbrisbin
Copy link
Member

A very recent update caused this:

 <script>
     $(function() {
       $(".accordion").accordion({
         collapsible: true,
         autoHeight:  false,                                                                                                                                                                                                                                                                                                
         active:      false
       });
    });

to all of sudden throw an "exception trying to run compile-time code...".

Changing to this:

  <script>
    \ $(function() {
    \   $(".accordion").accordion({
    \     collapsible: true,
    \     autoHeight:  false,                                                                                                                                                                                                                                                                                                
    \     active:      false
    \   });
    \ });

got it working, but I'd prefer to not need the extra escaping.

Any ideas why?

@snoyberg
Copy link
Member

This was a new feature request someone put in: flag all inappropriate commands as errors, to prevent typos like $for all. When I run your code, I get the more descriptive error message:

Received a command I did not understand. If you wanted a literal $, start the line with a backslash.
Code: Language.Haskell.TH.Quote.quoteExp
shamlet
"\r\n<script>\r\n $(function() {\r\n $(".accordion").accordion({\r\n collapsible: true,\r\n
autoHeight: false,\r\n active: false\r\n });\r\n });\r\n\r\n"

Having this feature also allows us to add new commands in the future without worries of breaking people's code.

@gregwebs
Copy link
Member

The way that this is handled in HAML & Slim is to allow switching to other parsers within html. :javascript indicates js. We could instead pass through all <script> tag content (there would still be a question as to variable insertion)

@snoyberg
Copy link
Member

Sounds like a can of worms to me, I'm not in favor of this. We should just make it easier to embed Julius and Lucius results into Hamlet. Which reminds me: we should switch over to blaze-builder instead of Data.Text.Lazy.Builder for the 1.0 release of shakespeare-(css|js).

@gregwebs
Copy link
Member

I had a few use cases that are easy & obvious to satisfy by passing through script/style content, but it isn't as obvious how to satisfy with an alternative technique.

<head>
    # put older browsers back to the root
    <script type="text/javascript">
      \top.noSVG = false;
      \if (!('pushState' in top.history)) {
        \if( 0 == location.pathname.indexOf('/sources/sr23/') ) {
          \top.location.href = '@{SearchR}#-' + location.pathname;
        \}
      \}

\<!--[if lt IE 9]>
    <script src=http://html5shim.googlecode.com/svn/trunk/html5.js>
    <script src=@{StaticR js_sie_js}>
    <script>
      \top.noSVG = true;
    <style type="text/css">
      div#energy-canvas  { height: auto; }
\<![endif]-->

I think my usage could be moved out of the template. They are little snippets, and in this case there is a global variable reference that is nice to have in the same file - it would be annoying to dedicate a file to each snippet. I could instead try to put functions using the julius quasi-quoter in one file and export them all to be available for the template.

@snoyberg
Copy link
Member

I don't know what the complication here is. If we have a "juliusToHamlet" or something along those lines, wouldn't it solve the problem?

@gregwebs
Copy link
Member

yes, and I also want to be able to have multiple julius snippets in one file- I may try to set this up in the scaffolding.

@snoyberg
Copy link
Member

I'm not sure what the status is of this issue currently. Can it be closed?

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

3 participants