Skip to content
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

Theme API: Helpers, naming and API friendliness #246

Closed
11 of 12 tasks
ErisDS opened this issue Jul 9, 2013 · 4 comments
Closed
11 of 12 tasks

Theme API: Helpers, naming and API friendliness #246

ErisDS opened this issue Jul 9, 2013 · 4 comments
Assignees

Comments

@ErisDS
Copy link
Member

ErisDS commented Jul 9, 2013

As it stands there are a few inconsistencies and oddities with the set of core helpers that we have on offer:

  • 1. Some helpers require double taches {{ and some require triple {{{ - triple taches are used to indicate that the content should not be escaped, but for helpers which always render HTML, the non-escaping should be managed with handlebars.SafeString()
  • 2. The nav and pagination helpers require that an object be passed to them, it is always the same object with the same name. As handlebars gets given the context, it should always have reference to the object and not require it to be passed. However, the current implementation obscures the context and prevents this.
  • 3. There should be a common way to override these defaults (i.e. a way to turn off using SafeString and to pass in a different object for the helper to use)
  • 4. Handlebars has support for async helpers, but we don't use it.
  • 5. We've got the concept of helpers which compile and use a template, which is awesome, but the code is being duplicated - I'd like to make this available as a core feature where we can simply register a name, a function and a template name and everything else is done
  • 6. Themes should be able to override the template, and our core template helper should pick that up and use it instead in Theme API: themes should be able to override templates used by helpers #294
  • 7. It might be nice to make template helpers also be block helpers - or is having 2 ways to override a little nuts? Pagination example for this is below.
  • 8. {{content_html}} is horrible... content should be come content_raw and content_html should become content - big breaking change alert! - to be done in 0.2: Theme API: Rename content fields #253
  • 9. We should introduce a {{content}} helper, which will override the content property (the html) and allow us to give the user options like length, or num words, or some such. Theme API - content helper #254
  • 10. Would be good to start keeping a list of, and raising issues for, other helpers we need such as post link, author, tags, etc
  • 11. Helpers need more test coverage - they're one thing we're exposing to users, so it would be good to ensure we can't break them or change their functionality without knowing about it.
  • 12. single.hbs - should be post.hbs (Ghost + Casper)

Example for 7. is on it's way

This is a big-arse issue I'm using for keeping track of Theme API related stuff, expect to see sub issues in the near future.

@ghost ghost assigned ErisDS Jul 9, 2013
@ErisDS
Copy link
Member Author

ErisDS commented Jul 10, 2013

I have 1, 2 and 5 done in a branch

ErisDS added a commit to ErisDS/Ghost that referenced this issue Jul 11, 2013
- updated navigation and pagination helpers to use SafeString
- nav and pagination don't need triple taches any more
- nav tests updated, and renamed to match helper name
ErisDS added a commit to ErisDS/Ghost that referenced this issue Jul 11, 2013
- moved template logic out of individual helpers and into Ghost
- simplified template-driven helpers into closures which maintain the context of handlebars
- with handlebars context we have access to data, so don't need to pass data in
- check data to test that it is a simple object and not a function
- moved helpers back into index.js
- provided tests for both template functions in ghost and the nav helper so we are back to where we were
ErisDS added a commit that referenced this issue Jul 11, 2013
-  renamed single.hbs to post.hbs
- casper updated to match
@ErisDS
Copy link
Member Author

ErisDS commented Sep 1, 2013

No more of this needs looking at right now, punting to 0.4

@JohnONolan
Copy link
Member

All looks done to me - at least in the context of September 2013. Suggest close and move future work to new issues

@ErisDS ErisDS removed this from the 0.8 Magazine milestone Aug 20, 2014
@ErisDS
Copy link
Member Author

ErisDS commented Aug 23, 2014

Agreed, there are things left to do but we're significantly further forward than we are and this issue doesn't really make sense anymore.

@ErisDS ErisDS closed this as completed Aug 23, 2014
morficus pushed a commit to morficus/Ghost that referenced this issue Sep 4, 2014
- updated navigation and pagination helpers to use SafeString
- nav and pagination don't need triple taches any more
- nav tests updated, and renamed to match helper name
morficus pushed a commit to morficus/Ghost that referenced this issue Sep 4, 2014
- moved template logic out of individual helpers and into Ghost
- simplified template-driven helpers into closures which maintain the context of handlebars
- with handlebars context we have access to data, so don't need to pass data in
- check data to test that it is a simple object and not a function
- moved helpers back into index.js
- provided tests for both template functions in ghost and the nav helper so we are back to where we were
morficus pushed a commit to morficus/Ghost that referenced this issue Sep 4, 2014
-  renamed single.hbs to post.hbs
- casper updated to match
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants