Git Product home page Git Product logo

grails-handlebars-resources's People

Contributors

chronodm avatar ghquant avatar roguejammin avatar sheehan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

grails-handlebars-resources's Issues

non minifiable tokens are not configurable

handlebars is a fairly long string for a token that can not be minified.

.hbm is a common suffix for handlebar templates
JST is a common namespace for Javascript Server Templates
it is common to have a map of template functions under JST ready to go rather than Handlebars.templates['templatename']

In a large app with many templates the extra characters add up, especially on mobile devices

Fails to bundle up the handlebar resource

I ran into the below issue

INFO: Initializing Spring root WebApplicationContext
| Error 2013-07-23 02:13:15,063 [localhost-startStop-1] ERROR handlebars.HandlebarsResourceMapper  - error precompiling
handlebars file: C:\Users\dipayan.b\.grails\2.2.3\projects\testapp\tomcat\work\Tomcat\localhost\testapp\grails-resources
\bundle-handlebars_defer.js
Message: D:\personalwork\grails-workspace\testapp\web-app\bundle-handlebars_defer.js, \templates\person.handlebars (The
system cannot find the path specified)
    Line | Method
->>  138 | <init>                        in java.io.FileInputStream
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|     43 | precompile                    in org.grails.plugin.handlebars.Precompiler
|     36 | map . . . . . . . . . . . . . in org.grails.plugin.handlebars.HandlebarsResourceMapper
|    139 | invoke                        in org.grails.plugin.resource.mapper.ResourceMapper
|    128 | invokeIfNotExcluded . . . . . in     ''
|    590 | applyMappers                  in org.grails.plugin.resource.ResourceProcessor
|    535 | prepareResource . . . . . . . in     ''
|    610 | doCall                        in org.grails.plugin.resource.ResourceProcessor$_prepareSingleDeclaredResource_
closure12
|     29 | addDeclaredResource . . . . . in org.grails.plugin.resource.util.ResourceMetaStore
|    608 | prepareSingleDeclaredResource in org.grails.plugin.resource.ResourceProcessor
|    657 | prepareResourceBatch . . . .  in     ''
|    813 | resourcesChanged              in     ''
|    809 | loadModules . . . . . . . . . in     ''
|   1078 | reloadAll                     in     ''
|    172 | doCall . . . . . . . . . . .  in ResourcesGrailsPlugin$_closure3
|    334 | innerRun                      in java.util.concurrent.FutureTask$Sync
|    166 | run . . . . . . . . . . . . . in java.util.concurrent.FutureTask
|   1145 | runWorker                     in java.util.concurrent.ThreadPoolExecutor
|    615 | run . . . . . . . . . . . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^    724 | run                           in java.lang.Thread
| Server running. Browse to http://localhost:8080/testapp

ApplicationResources.groovy file content is given below:

modules = {
    application {
        dependsOn 'handlebars_runtime'
        resource url: 'templates/person.handlebars', attrs: [type: 'js'], bundle: 'handlebars'
        resource url:'js/application.js'
    }
}

BuildConfig.groovy

plugins {
        runtime ":hibernate:$grailsVersion"
        runtime ":jquery:1.8.3"
        runtime ":resources:1.2"

        // Uncomment these (or add new ones) to enable additional resources capabilities
        //runtime ":zipped-resources:1.0"
        //runtime ":cached-resources:1.0"
        //runtime ":yui-minify-resources:0.1.5"

        build ":tomcat:$grailsVersion"

        runtime ":database-migration:1.3.2"

        compile ':cache:1.0.1'
        runtime ':handlebars-resources:0.3.6'
    }

Grails version : 2.2.3

Q: how does the plugin handle 'known template helper functions' ?

nice plugin !

just wondering though, usually I have a bunch of template helper functions defined e.g.
Handlebars.registerHelper('someFunction', function () { .. etc

And then I would compile using -k flag to 'register' the template helper function e.g.
handlebars rawTemplate.handlebars -f output_dir/compiledTemplate.js -k someFunction

does the plugin support this?

handlebars-resources plugin breaks with grails.resources.debug = true

David Tinker [email protected] via grails.codehaus.org

6:52 AM (4 hours ago)

to dev
My app runs fine unless I set grails.resources.debug = true. Then I
get a 404 for this request:

http://localhost:8022/js/handlebars.runtime-1.0.0.beta.6.js?_debugResources=y&n=1346931957085

All the other js libs load fine including jQuery which also comes from
a plugin. Turning off grails.resources.debug so the js files are
bundled together works.

Any ideas?

handlebars-resources-0.3
resources-1.2-RC1
jquery-1.7.2

Grails 2.1.0

Create a handlebars taglib for server-side rendering

This is perhaps a bit of a pipe dream, but it would be really nice to use the same templating library both on the client and server-side (esp for SEO purposes). I suppose that's one aspect that makes node appealing.

What are your thoughts on creating a grails taglib that executes a mapped handlebar template in a GSP? For example:

<g:each in="${items}" var="item">
   <r:handlebars template="someTemplate" value="${item}"/>
</g:each>

Question: Production vs. Development

In "development" mode it seems I need to pre-compile my handlebars, but in production mode the handlebars templates are compiled for me. So, in production, the plugin wants mustache templates, while in development mode, it wants precompiled handlebars as JavaScript functions.

What is the suggested approach for making things work nicely both in development and in production? What am I doing wrong?

Cannot use handlebars_runtime with grails.resources.debug = true

Love what you've done with this plugin, but I've run into a workflow issue.

I would like to use the handlebars_runtime dependency to prevent having to compile on the client side (really important for mobile clients). However, I also like setting grails.resources.debug=true in the Config.groovy while I'm in development mode, so that my JS and CSS files can get automatically reloaded.

Problem is, in debug mode, the resource mappers don't run (of course). So the raw handlebars file gets transferred instead, and in Chrome I see the error:

Resource interpreted as Script but transferred with MIME type text/html: "http://localhost:8080/[...]/filename.hbs[...]
Uncaught SyntaxError: Unexpected token < 

And of course, I can't call Handlebars.templates['my-template-file'] on the client side like I normally would, since it wasn't precompiled.

Of course I can just set grails.resources.debug=false, but then I don't get automatic reloading of JS/CSS, meaning I have to keep re-launching grails run-app every time I change a line in a JS file.

Unfortunately, since Grails doesn't seem to allow per-mapper resource debugging, I don't see an easy way to fix this. So I guess my question is: what workflow do you use with your own plugin? Do you just re-launch grails run-app whenever you change a JavaScript file?

As an aside, I searched GitHub for instances of people using your plugin and I found two groups: 1) those who were not using grails.resources.debug=true, and 2) those who were, but who had commented out your plugin. So it seems I'm not the only one who has had issues. :)

Thanks again for your excellent work.

Templates not compiled when production doesn't use expanded WAR

Love the plugin, thanks for the work on it.

I've run into an issue whereby deployments that don't use the expanded WAR don't compile the .hbs files and simply spit them out in the page as JS files with uncompiled content (breaking the JS).

I have tracked this down to this log line:

ServletContext resource [/console/templates/message.hbs] cannot be resolved to absolute file path - web application archive not expanded?

Which then led me to:

paulfairless/grails-lesscss-resources#8

This fix basically uses a URL for the input resource, rather than a file on the filesystem; one suggestion is that Tomcat may not return a URL for unknown MIME types.

Anyway, I have applied the above patch (albeit quite crudely) to my local copy of the plugin and this has confirmed to work in production with an unexpanded WAR file.

Is this something that could go into the plugin?

Thanks!

Sebastian

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.