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

Built-in View Helpers #233

Closed
jescalan opened this issue Sep 26, 2013 · 9 comments
Closed

Built-in View Helpers #233

jescalan opened this issue Sep 26, 2013 · 9 comments
Labels

Comments

@jescalan
Copy link
Owner

So sometimes I miss rails' built-in view helpers that generally make life a lot easier with regards to parsing strings especially. I think it would be cool to include a couple of modules that help out with common tasks that you might need in views.

Reference: http://api.rubyonrails.org/classes/ActionView/Helpers/TextHelper.html

It's worth thinking about how we could modularize and package up these helpers as well. Should we just include them in views and document them, or offer a way for users to toggle them on, etc.

@jescalan
Copy link
Owner Author

Just came across this library, which I think would be a greats staring point for the view helpers: https://github.com/HubSpot/humanize

@jescalan
Copy link
Owner Author

Here's another great one for dates. Would be killer if moment was built in: http://momentjs.com/

@zspecza
Copy link
Contributor

zspecza commented Oct 28, 2013

I've used moment before. It is super awesome - would trust it over the HubSpot one any day (any code I've used from HubSpot breaks bower in roots so I no trusty) in terms of time formatting. For capitalizing, titleizing and the like, I'd use underscore.string.

@samccone
Copy link
Collaborator

+1000 momentjs

@jescalan
Copy link
Owner Author

jescalan commented Nov 3, 2013

Woah, underscore.string looks great. I'll look into that a little further, but looks incredible.

@zspecza
Copy link
Contributor

zspecza commented Nov 4, 2013

underscore.string is great, I used it for string manipulation to test out my CSS preprocessor idea, as I didn't have any knowledge of compilers at the time. But now I've got an understanding of parsing, tokenizing and so on. :) underscore.string gave me nothing but joy at the time! You'll enjoy it too, for sure.

@jescalan
Copy link
Owner Author

jescalan commented Nov 6, 2013

This feature has landed on the release branch. Roots ships with underscore, underscore.string, and moment by default, and you can also include your own view helper bundles through app.coffee. Whoo!

@jescalan jescalan closed this as completed Nov 6, 2013
@airtonix
Copy link

@Jenius can you elaborate more on how we can bundle our own view helpers?

ideally I was hoping for this :

locals:
  something: ""
  something: ""
  something: ""
  darkside: require './view_helpers/darkside' 

Or even better, simply require each file in config.view_helpers directory:

module.exports.darkside = (something) ->
 ...

@jescalan
Copy link
Owner Author

@airtonix You can do it this way with roots v3, which is currently what's being actively developed. You can test out the latest v3 prerelease with npm i roots@pre -g.

In v3, you can run this in your app.coffee file and it will work:

module.exports =
  ignore: ['view_helpers/*']
  locals:
    foo: require('./view_helpers/foo')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants