-
Notifications
You must be signed in to change notification settings - Fork 74
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
How to create a helper with a template var in the attributes? #66
Comments
I'm not 100% on what you mean here, there are a couple of things that I can think of that might be pertinent: Subexpressions in handlebars use parenthesis, which is supported
except there is a known issue if the inner helper is async. Inside a helper function the attributes passed in are accessible through There are quite a few examples of helpers in the Ghost codebase that might lead you to what you're looking for. Alternatively if you post the code you would expect to write for |
Sod. I know where I'm going wrong (though I don't have the solution). I was expecting @ErisDS I'm impressed you picked up this issue, it was because I spelunking the Ghost code looking to make a fix (which also includes this PR). What I actually was is this to work (though perhaps this belongs in the Ghost repo?): <section class="post-excerpt post-content">
{{content words="50" append='[…] <a class="read-more" href="{{url}}">Read more »</a>'}}</p>
</section> I've updated the coreHelpers.content = function (options) {
var truncateOptions = (options || {}).hash || {};
truncateOptions = _.pick(truncateOptions, ['words', 'characters', 'append']);
// ...etc This way I hope to use the I did try swapping ...should I also close this issue and open a new one for this topic against Ghost? |
Haha, this is a pretty core module to Ghost, so I try to pay attention. With regard to your downsize PR it's not documented, but that feature already exists and it's called contextualTags. Furthermore, the guy who added it then PR'd to Ghost but it didn't make it in due to us relying on a feature in older versions of downsize, which only just got resolved - now we need to work out if it's a useful implementation for the Ghost Theme API, and if so how to add it (we don't add stuff to the Theme API without careful consideration). With regard to having an The final issue you've got here is that |
Okay, closing this issue since it's not applicable. I'll raise my case for append (well, I'll search first). I believe there's a case, or the alternative is to remove functionality. |
Heh, or just add my comments to the existing thread! |
My apologies if I come with preconceptions, I'm used to https://github.com/donpark/hbs - but I wanted to know if it was possible to handle the following in a template:
{{link '{{url}}' href='http://{{url}}'}} <!-- should output: <a href="http://foo.com">foo.com</a> -->
This is a contrived example, but I don't understand how I can process the attributes from inside the helper. I'm normally used to applying
options.fn
but that's not available in your adapter. Is this possible at all?The text was updated successfully, but these errors were encountered: