GithubHelp home page GithubHelp logo

Compile on the fly about coffeekup HOT 7 CLOSED

ouvanous avatar ouvanous commented on August 16, 2024
Compile on the fly

from coffeekup.

Comments (7)

ouvanous avatar ouvanous commented on August 16, 2024

forget to tell that render a template in a template via coffeekup command line ?

from coffeekup.

mauricemach avatar mauricemach commented on August 16, 2024

Hi Samuel,

"compile automatically like coffee -cw" - I'm all for that. In fact the CLI tool needs some love. I'll work on it and post back here when it's ready.

nested rendering - You can certainly do this already, see this gist. You can even define it as a local (just render instead of @render), which I think is preferrable since the context (@) is a good namespace for data.

Just remember that this approach is synchronous, it's opening a file and blocking until the contents can be returned, so it's not a good fit for run time. But for the CLI it would certainly make sense, since blocking at build time is usually not an issue. So I think we could have the CLI tool include a render local like this for us automatically, even though it's not in the library itself. Is that what you're thinking too?

from coffeekup.

ouvanous avatar ouvanous commented on August 16, 2024

Hi Maurice and thanks for your response.
That is exactly what i need !
I want to use coffeekup for prototyping with less for css.
So i can use template and component (e.g nav.coffee, layout.coffee, ...) and generate (automatically) by command line (with watch options the html files)
The code with coffeekup is extremly clear : thanks ;-)
Is it possible to have html generated formatted correctly ? (with indent and new lines, ...)
I think that the code generated now isonly in one line ?
I don't know if you know less.app ? http://incident57.com/less/ but this is how i use css now it is extremly quick to prototype with it.
Based on you recommandations i've done this that is what i need for now
ck = require 'coffeekup'
fs = require 'fs'
sys = require 'sys'
fs.readdir('.', (err, files)->
files.forEach((f)->
if (f.indexOf '.coffeekup')
render f
watch f
)
)
render = (file) ->
code = fs.readFileSync file, 'utf8'
ck.render code, context: @

watch = (source, base) ->
fs.watchFile source, {persistent: true, interval: 500}, (curr, prev) ->
return if curr.size is prev.size and curr.mtime.getTime() is prev.mtime.getTime()
fs.readFile source, (err, code) ->
throw err if err
sys.log ck.render(code.toString(), locals: {render: render})

Many thanks,

Samuel

from coffeekup.

mauricemach avatar mauricemach commented on August 16, 2024

Just pushed a new version with:

-w: Watches and recompiles just like coffee

-u: Adds helper locals to your templates (only render currently)

-f: Formats the output HTML with line breaks. I'll add indentation too in the future. This option is also available from the API (CoffeeKup.render tpl, format: yes)

Please tell me if I got it right!

from coffeekup.

mauricemach avatar mauricemach commented on August 16, 2024

PS: This version is not on npm yet, to check it out you can clone the repo and run npm link . at the package dir.

from coffeekup.

ouvanous avatar ouvanous commented on August 16, 2024

Wow ! many thanks Maurice.
I will test that this evening but it seems very nice.
Once i 'll have little time I will try to make a little logo for coffeekup ;-)
Many thanks again !

from coffeekup.

mauricemach avatar mauricemach commented on August 16, 2024

Well that would be great!

I've been thinking of something along the lines of a coffee... cup... between brackets. But if you think it's too cheesy, I can certainly understand! =D

from coffeekup.

Related Issues (20)

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.