vim-rails icon indicating copy to clipboard operation
vim-rails copied to clipboard

Projections: handling partial view names

Open dasch opened this issue 12 years ago • 6 comments
trafficstars

I'm using projections for Curly in order to jump from a template to a presenter and back. I've currently got this JSON:

{
  "app/presenters/*_presenter.rb": {
    "affinity": "controller",
    "command": "presenter",
    "test": "spec/presenters/%s_presenter_spec.rb",
    "related": "app/views/%s.html.curly",
    "template": "class %SPresenter < Curly::Presenter\nend",
    "keywords": "presents depends_on version"
  },

  "app/views/*.html.curly": {
    "affinity": "controller",
    "test": "spec/views/%s_spec.rb",
    "related": "app/presenters/%s_presenter.rb"
  }
}

It works fine for normal views, but breaks down for partials – app/views/foo/_bar.html.curly should go to app/presenters/foo/bar_presenter.rb and vice versa – the problem is that %s expands to foo/_bar. It would be great if there was support for these additional formats:

  • The leading path up to but not including the last part, i.e. foo/bar/baz would become foo/bar.
  • The last part, i.e. foo/bar/_baz would become _baz.
  • The last part excluding any leading underscore, so foo/bar/_baz would become baz.

That would fix my problems I think.

dasch avatar Jun 05 '13 10:06 dasch

@dasch have you taken a shot at fixing this yourself in vim-rails? If not, wanna pair on it?

prognostikos avatar Aug 21 '13 09:08 prognostikos

@prognostikos sure!

dasch avatar Sep 24 '13 14:09 dasch

I haven't gotten around to looking at fixing it myself.

dasch avatar Sep 24 '13 14:09 dasch

I aim to port over the slightly different expansions from projectile.vim in the near future. This should enable solving half the problem with {dirname}/_{basename}. Speak up in tpope/vim-projectile#3 if you have ideas for the other half.

tpope avatar Mar 29 '14 20:03 tpope

@dasch did you ever get a configuration that works with curly set up?

prognostikos avatar Mar 01 '16 08:03 prognostikos

Nah, never got around to it.

dasch avatar Mar 01 '16 11:03 dasch