Comments (8)
It'd be nice indeed. But that would require a different implementation model I think. Currently when you execute a method like "span" you're writing to a buffer. To get the output in the order you expect we should change to a model based on return values instead, which I'm not sure is feasible. Do you have an idea on how this could work?
from coffeekup.
a proposal, and a pull request!
h2 -> "Spinning the #{span.inline 'Real-time'} Web"
my implementation adds a 'buffers' array, and pushes/pops buffers using __ck.start
and __ck.stop
. __ck.stop
returns old_buffer.join('')
, which in a round-about way gets pushed onto the old buffer.
see gist 1213040 or commit dc175e2a03
from coffeekup.
Insteresting approach!
I experimented further with your idea and ended up just this in the skeleton:
inline = (f) ->
temp = []
old = __ck.buffer
__ck.buffer = temp
f()
__ck.buffer = old
temp.join ''
Then we can write:
p "This text could use #{inline -> strong -> a href: '/', 'a link'}."
In other words, with inline
you can get the output of a template chunk as a return value instead of having it write to the buffer.
What do you think?
I'm still not happy with the name "inline", I'd prefer something shorter and closer to the meaning of what's being done (returning instead of writing to the buffer).
from coffeekup.
I dig it! I was at a loss as to how one could avoid #{strong.inline -> a.inline ...}
. I was thinking that a lot of use cases would be for just one or two tags, so the .inline
repetition wouldn't be a big deal. But it doesn't have the taste of "solution that works for all situations". Better, I think, to have one function that does that, rather than a bunch of .inline
fn's (though, I do love to opportunity to treat functions like objects).
AFA the name... well, it's funny & annoying how often naming gets in the way of all the fun...
p "#{embed->strong->em 'What'} would go well there?"
p "#{here->strong->em 'What'} would go well there?"
p "#{plant->strong->em 'What'} would go well there?"
p "#{o->strong->em 'What'} would go well there?"
Good luck with that decision! I can't say I like any of these (or dislike one more than another). I just wanted to see what they looked like in code.
from coffeekup.
I love function.function
too, and I'll surely exploit it more in the future with coffeekup and zappa.
Yes, most use cases will be really short, and I think even the function -> chunk
solution is still too bloated for that. But I guess the only room for improvement here is picking a shorter name.
Ditto, naming is freaking annoying... but I can't help it. :) I need meaningful, short names to compensate for my limited brain.
BTW, I'll put your git username and email in the contributors list, if you don't mind.
from coffeekup.
Hey, you're jj's author! :) I found it today and it seems very interesting, though I wasn't able to have a closer look yet (npm has been acting funny today).
from coffeekup.
I am indeed! It's exciting to have it noticed so quickly after its inception. Soon here I'm going to spend a hefty chunk of time getting some more packages in there.
And of course I'd be honored to be mentioned on the contributors list :-)
from coffeekup.
Thanks to @smathy for the name.
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.