GithubHelp home page GithubHelp logo

Asset path helpers about gulp-rails-pipeline HOT 7 OPEN

rymohr avatar rymohr commented on June 5, 2024
Asset path helpers

from gulp-rails-pipeline.

Comments (7)

lneffa avatar lneffa commented on June 5, 2024

@rymohr thanks for the links, I have a question about using ActionView helpers...
How can I have Gulp tasks build up assets and dump them into ./public/assets while being able to use helpers? I have, for example with html files, been using gulp-ruby-haml which allows me to use Ruby, but no helper methods are accessible.. Would love to be able to precompile html locally and in the preprocessing be able to use helpers.

Am I going in the right direction?

from gulp-rails-pipeline.

rymohr avatar rymohr commented on June 5, 2024

Sorry @audeamus22 I haven't actually started using this library yet. Maybe @greypants can help.

from gulp-rails-pipeline.

lneffa avatar lneffa commented on June 5, 2024

Ok thank you, any suggestions @greypants ?

from gulp-rails-pipeline.

greypants avatar greypants commented on June 5, 2024

Hmm... I guess it could make sense to just add gulp/assets as the first directory searched, then fallback to the old asset pipeline directories (`app/assets, 'vendor/assets', etc). I'll definitely look into it (or feel free to open a pull request)

@audeamus22 Not sure about gulp-ruby-haml - this setup continues to use Rails views for markup, and the gulp_asset_path helper is available to them, and you can use that with regular html for now.

haml

%img{src => gulp_asset_path('images/foo.png')}

erb

<img src="<%= gulp_asset_path('images/foo.png') %>" >

from gulp-rails-pipeline.

lneffa avatar lneffa commented on June 5, 2024

Thank you @greypants, I have gotten the gulp_asset_path working great when implemented through Rails views markup. I am presented with the following challenge and can't seem to figure it out:

I am using a client framework (Auriela / Durandal to be specific). This framework has not supported the use of javascript function templates that can be accessed and re-used client side. Also, this framework uses module ids to fetch from the server specific html files, such as:
/assets/javascripts/common/main_nav/main_nav.html
Aurelia / Durandal expects an html file response.

Knowing how there are gems to output js templates ( such as this one: https://github.com/dnagir/ruby-haml-js ), the ability to use these gems to configure the assets:precompile build works. These configurations allow for the client to tap into whatever logic Rails and the ActionView helpers can provide --- all through a global JST function spit out by the gem. link_to, form_for, gulp_asset_path all can work inside these *.jst.hamljs files.

I'm looking for a way to take your gulp task setup and modify it so I can tap into link_to, form_for, gulp_asset_path, and be able to generate html files that are dumped to ./public/assets/javascripts/**/*.html. Or alternatively, if it is not possible to run a gulp task to do this, is there a way to get Rails to serve these .html files back on getting requests from Aurelia / Durandal? And if Rails is able to serve these .html files, does that mean I would have to set config.assets.compile = true in production.rb config?

I really appreciate your help, thank you.

from gulp-rails-pipeline.

rymohr avatar rymohr commented on June 5, 2024

@greypants was going to open a PR but wanted to make sure I didn't break anything. Did I miss something or is there no test suite?

from gulp-rails-pipeline.

greypants avatar greypants commented on June 5, 2024

Wild west. No test suite yet. 😨

I'll open an issue to add one.

from gulp-rails-pipeline.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.