-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
ryan tulino
committed
Apr 30, 2018
1 parent
1643c6f
commit 7593f4e
Showing
8 changed files
with
121 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,45 @@ | ||
# path-hints | ||
# ActivePath Path Hints: | ||
|
||
Path hints for your Rails 5 partials. | ||
|
||
## Installation | ||
|
||
Add to your Gemfile: | ||
|
||
```ruby | ||
gem 'active_path-path_hints' | ||
``` | ||
|
||
Add the initializer `config/initializers/active_path.rb` and enable `ActivePath`: | ||
|
||
```ruby | ||
|
||
ActivePath.configure do |config| | ||
|
||
config.enabled = true | ||
|
||
end | ||
|
||
``` | ||
|
||
**Path hints:** (use in development only) | ||
|
||
|
||
```ruby | ||
|
||
config.path_hints = true | ||
|
||
``` | ||
|
||
HTML comments are added before and after each partial. Here is sample output: | ||
|
||
```html | ||
<!-- start pages/content --> | ||
<p>page content</p> | ||
<!-- end pages/content --> | ||
<!-- start example/test --> | ||
<p>example content</p> | ||
<!-- end example/test --> | ||
|
||
``` | ||
Feel free to [submit issues](https://github.com/active-path/path-hints/issues) or [help make it better](https://github.com/active-path/path-hints/pulls). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/usr/bin/env rake | ||
|
||
$LOAD_PATH.unshift File.expand_path('../lib', __FILE__) | ||
require 'active_path/path_hints/version' | ||
|
||
desc "Release version #{ActivePath::PathHints::VERSION} of the gem" | ||
task :release do | ||
|
||
system "git tag -a v#{ActivePath::PathHints::VERSION} -m 'Tagging #{ActivePath::PathHints::VERSION}'" | ||
system 'git push --tags' | ||
|
||
system "gem build active_path-path_hints.gemspec" | ||
system "gem push active_path-path_hints#{ActivePath::PathHints::VERSION}.gem" | ||
system "rm active_path-path_hints#{ActivePath::PathHints::VERSION}.gem" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
$:.push File.expand_path('../lib', __FILE__) | ||
require 'active_path/path_hints/version' | ||
|
||
Gem::Specification.new do |s| | ||
s.name = 'active_path-path_hints' | ||
s.version = ActivePath::PathHints::VERSION | ||
s.date = '2018-04-28' | ||
s.summary = "ActivePath Path Hints" | ||
s.description = "Path hints for your Rails 5 partials" | ||
s.authors = ["Ryan Tulino"] | ||
s.email = '[email protected]' | ||
s.files = `git ls-files`.split("\n") | ||
s.homepage = 'http://rubygems.org/gems/active_path-path_hints' | ||
s.required_ruby_version = '>= 2.2.0' | ||
s.add_dependency 'rails', '~> 5' | ||
s.add_dependency 'active_path', '~> 0.1.0' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
require 'active_path/path_hints/engine' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
require 'active_path/path_hints/subscriber' | ||
module ActivePath | ||
module PathHints | ||
class Engine < Rails::Engine | ||
isolate_namespace ActivePath::PathHints | ||
|
||
config.after_initialize do | ||
if ActivePath.config.path_hints | ||
ActiveSupport::Notifications.subscribe(:render_partial, Subscriber.new) | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
require 'active_path/subscribers/subscriber' | ||
module ActivePath | ||
module PathHints | ||
class Subscriber < Subscribers::Subscriber | ||
def perform | ||
buffer.prepend("<!-- start #{partial}#{with_local_variables.to_s} --!>".html_safe) | ||
buffer.concat("<!-- end #{partial} --!>".html_safe) | ||
end | ||
|
||
private | ||
|
||
def with_local_variables | ||
if options.is_a?(Hash) | ||
variables = options[:locals].map do |k,v| | ||
count = (" (#{v.count})" if v.is_a?(Array)).to_s | ||
"#{k} => #{v.class}#{count}" | ||
end | ||
"\nwith local variables: #{JSON.pretty_generate(variables)}" | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module ActivePath | ||
module PathHints | ||
VERSION = '0.1.0' | ||
end | ||
end |