diff --git a/.gitignore b/.gitignore index a3f3ae8..5b85578 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ pkg/* **/*/log/* **/*/tmp/* Gemfile.lock +.idea/* diff --git a/.rvmrc b/.rvmrc index c07e01a..e5b4586 100644 --- a/.rvmrc +++ b/.rvmrc @@ -1 +1 @@ -rvm use default@handlebars_assets +rvm use --create ruby-head@slim diff --git a/README.md b/README.md index 78a30de..615fdcf 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,14 @@ # Use slim to write your Javascript templates -*ALPHA* +This is a fork of the wonderful slim_assets (https://github.com/crowdint/slim_assets) to work with Rails 4 & Ruby 2. -[![Build Status](https://secure.travis-ci.org/crowdint/slim_assets.png)](http://travis-ci.org/crowdint/slim_assets) - -Writing Javascript templates for Backbone.js (or other frameworks) in your app? Would you like to use slim and the asset pipeline? - -This gem adds slim templating support to the Rails 3.1 asset pipeline. This gem works with the EJS gem and JST asset engine to make your slim available as a compiled Javascript template. +Use this to write Backbone.js or AngularJS templates in Slim and let the Rails asset pipeline take over. ## Installing Add this to your `Gemfile` - gem 'slim_assets' - gem 'ejs' + gem 'slim_assets', github: 'jigyasam/slim_assets, branch: 'jigyasam/rail4' gem 'slim' # Using slim for your Javascript templates @@ -28,32 +23,25 @@ You should locate your templates under `app/assets`; we suggest `app/assets/temp Inside your templates directory, add your template file. The file should be named as follows - your_template_name.jst.ejs.slim + your_template_name.html.slim The asset pipeline will then generate the actual Javascript asset -1. Convert your slim to HTML -1. Compile the HTML to an EJS Javascript template -1. Add the template to the JST global under the templates name - **Important!** The asset pipeline is not invoking a controller to generate the templates. If you are using existing view templates, you may have to edit templates to remove some references to controller helpers. -## EJS +### Helpers -In your template file you can use the EJS delimiters as you would normally. If you want to use them in attributes mark the attribute html_safe. +All the ActionView and route helpers are available in your template. Eg: - = f.text_field :email, class: 'text', value: '<%= email %>'.html_safe +ul + li = link_to "Home", home_path -### Helpers +### Angular template variables & directives work. Eg: -All the ActionView and route helpers are available in your template. If you use `form_for` and the related helpers, you should use the *new* object form, even if you are writing an *edit* form, for example +div.items data-ng-repeat="item in items" {{ item }} - = form_for :contact, url: "javascript_not_working", html: {:class => :edit_contact, :method => :put} do |f| - %p - = f.label :name, "Name" - = f.text_field :name, class: 'text required', autofocus: true, value: '<%= name %>'.html_safe -# Credits +# Original Credits * Les Hill : @leshill * Wes Gibbs : @wgibbs diff --git a/lib/slim_assets/version.rb b/lib/slim_assets/version.rb index 8c4ec7a..e4ec62f 100644 --- a/lib/slim_assets/version.rb +++ b/lib/slim_assets/version.rb @@ -1,3 +1,3 @@ module SlimAssets - VERSION = "0.0.2" + VERSION = "0.0.3" end diff --git a/slim_assets.gemspec b/slim_assets.gemspec index 7c10561..95a718c 100644 --- a/slim_assets.gemspec +++ b/slim_assets.gemspec @@ -21,7 +21,7 @@ Gem::Specification.new do |s| s.add_runtime_dependency "slim" s.add_runtime_dependency "tilt" - s.add_development_dependency 'rails', '~> 3.1.0' + s.add_development_dependency 'rails', '4.0.0.beta1' s.add_development_dependency 'sqlite3' s.add_development_dependency 'rspec' s.add_development_dependency 'rspec-rails'