Comments (7)
forget to tell that render a template in a template via coffeekup command line ?
from coffeekup.
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.
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.
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.
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.
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.
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)
- DryKup, a fork of CoffeeCup HOT 1
- unused tags research
- Asynchronous document support
- using coffeekup with express
- How to include javascript body?
- How to access tag helpers from a different scope (e.g. inside a helper object instance)? HOT 1
- coffeekup cli not working with coffeescript 1.2 HOT 10
- svg tag support
- Lack of a unescape/safe helper when autoescape in on HOT 1
- Still alive? HOT 29
- Blocks / place holders in layouts HOT 2
- enabling and disabling button HOT 1
- CoffeeScript is going to make "yield" the reserved word HOT 3
- This project is dead? HOT 7
- you may be interested in this alternative: coffee-templates HOT 3
- Incorrect package.json HOT 4
- How To Refactor Right? HOT 1
- How to define custom tags?
- Is this project dead? HOT 26
- Moving to new github organisation for the longer suatainablity and maintenance of the project: New Org Coffeekup HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from coffeekup.