cannot load stylus in slim template - slim-lang

when I am trying to use the styl: tag in the stylus file I am not able to compile it...here is the error I am getting.
Temple::FilterError: Tilt engine styl is not available.
Use --trace for backtrace.

Add the patch to tilt registeration.
require 'stylus/tilt/stylus'
register StylusTemplate, 'stylus'

Related

‘No such file or directory - pandoc’ when trying to use :markdown filter in haml-rails

I am trying to use the :markdown filter with haml-rails on Rails 5.0.2.
When I first tried to use Markdown in a HAML file, it said it needed pandoc-ruby as a dependency, so I added that to my Gemfile. However, now when I try to use :markdown inside my file, I am getting the following error:
You don’t need Pandoc here, that’s just the first markdown processor Tilt tries to use and reports if it can’t find any others. You do need some markdown processor though.
Your simplest fix would probably be to remove pandoc-ruby from your Gemfile and add a Ruby markdown processor (e.g. kramdown).
If you need more control over which processor Haml uses (e.g. if you want to use kramdown for Haml filters but have RedCarpet in your app for something else), try something like this in an initializer:
require 'tilt/kramdown'
module Haml::Filters
remove_filter("Markdown")
register_tilt_filter "Markdown", :template_class => Tilt::KramdownTemplate
end
If you do want to use Pandoc for rendering markdown then you need to make sure it’s installed, see Chris’ answer.
From its README:
PandocRuby is a wrapper for Pandoc, a Haskell library with command line tools for converting one markup format to another.
It requires Pandoc to be installed separately (emphasis added):
First, make sure to install Pandoc.
Next, add PandocRuby to your Gemfile
gem 'pandoc-ruby'

Retain Sass syntax highlighting in Sublime Text 2 when embedding Ruby

I am embedding Ruby in a few Sass files—I have files named, for example, file.css.scss.erb. When I add the .erb extension to these files, I lose the Sass syntax highlighting. Does anyone know how to retain the Sass formatting?
Open your .sass.erb file, and go to :
View > Syntax > Open all with current extension as... > Sass

Sprockets::FileNotFound when trying to include a jQuery gem

I'm trying to use https://github.com/linjunpop/jquery-tablesorter-rails to sort my tables. I'm running into issues when trying to include the CSS:
/*
* = require jquery-tablesorter/blue
*/
Error message:
Sprockets::FileNotFound: couldn't find file 'jquery-tablesorter/blue'
I do see the Gem being loaded in the config path:
1.9.3p194 :008 > Rails.application.config.assets.paths.each { |x| puts x }
.rvm/gems/ruby-1.9.3-p194/gems/jquery-tablesorter-1.0.5/vendor/assets/images
.rvm/gems/ruby-1.9.3-p194/gems/jquery-tablesorter-1.0.5/vendor/assets/javascripts
.rvm/gems/ruby-1.9.3-p194/gems/jquery-tablesorter-1.0.5/vendor/assets/stylesheets
Any idea what the issue could be?
Can't reproduce. Usually when this kind of things happen to me is because of forgetting to restart the dev server after bundling a new gem. Sprockets tries to build or resolve a new set of assets, but the loaded environment is the same as before, so the additional asset can't be found.
The corret path is:
*= require jquery-tablesorter/theme.blue
I've updated Tablesorter to use themes in version 2.4+, so the blue theme file has been renamed and moved to a different directory.
I don't know much about Ruby, or that repo but you might want to get Tablesorter v2.3.11 until that repo has been updated (see this issue in that repo).
I'm seeing the path you're requiring as a directory; the error message seems to indicate that it's failing to find a file. Have you tried
*= require jquery-tablesorter/blue/*
instead?

How to generate KML file in ruby?

I'd like to serve a dynamically generated KML file using ruby on rails. I made some research and I found kamel which looks great. The problem is that kame depends on ruby_kml gem which doesn't seem to be available anymore.
$ gem install kamel
ERROR: While executing gem ... (Gem::DependencyError)
Unable to resolve dependencies: kamel requires ruby_kml (~> 0.1.4)
Searching 'kml' on rubygems.org was unsuccessful.
So does someone know any alternative to achieve KML generation in ruby on rails?
KML is just another XML, you can easily make your own "writer" which parses recursively and formats whatever input is passed in as a parameter and generates a string that looks like valid KML/XML.
Recommended reading for the options and the XML layout:
https://developers.google.com/kml/documentation/kmlreference

Rails assets:precompile strange behavior

I found myself in front of a strange behavior of the assets:precompile task, or at least in front of something I don't fully understand.
So, I am using Rails 3.1.3, Sprockets 2.0.3, Less 2.0.11 for my web application, plus I rely on Bootstrap for the layout, so I am using also less-rails 2.1.8 and less-rails-bootstrap 2.0.8.
I have customized the style like they say here.
The configuration of my assets is:
stylesheets
|--application.css.scss
|--custom-style/
|--variables.less
|--mixins.less
|--buttons.less
|--custom-style.css.less
In application.css.scss I do
//=require custom-style
And in custom-style I do
#import "twitter/bootstrap/reset";
//#import "twitter/bootstrap/variables"; // Modify this for custom colors, font-sizes, etc
#import "custom-style/variables";
//#import "twitter/bootstrap/mixins";
#import "custom-style/mixins";
// And all the other standar twitter/bootstrap imports...
// Other custom-style files to import
#import "custom-style/buttons"
//...
// And other rules here
//...
Finally in buttons.less I use some variables and mixins defined in the variables.less and mixins.less Bootstrap files, #white and .buttonBackground to be more specifc.
If I launch bundle exec rake assets:precompile with the above configuration, the task fails and I get this error:
$ bundle exec rake assets:precompile
/usr/local/rvm/rubies/ruby-1.9.3-p0/bin/ruby /usr/local/rvm/gems/ruby-1.9.3-p0/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets
rake aborted!
.buttonBackground is undefined
But is that if I do this changes
buttons.less --> buttons.css.less
#import "buttons" --> #import "buttons.css.less"
Everything works fine!!
Is it something related to the scope of less variables and functions when working with nested imports? Or something that has to do with the order the less parser, or Sprockets, processes the import tree?
Am I missing something or doing something in the wrong way?
Thanks :)
Note: I get the error even with the original variables and mixins files, so it's not connected with the overrides done into them.
I can think of one of two possibilities right now:
1) You should change application.css.scss to application.css.less and use:
#import "custom-style";
instead of the sprockets //= require ...
2) The LESS compiler is very finicky about its semicolons. I noticed that you have
#import "custom-style/buttons" - it should be #import "custom-style/buttons";
Dunno if the issue is really that simple, but it's a start.
Have you tried renaming the file to buttons.css.less but keeping the extension off the #import (i.e., #import "buttons")?
That's how I do it with SCSS and it works fine.
Another thought is to replace the //=require custom-style in application.css.less with an #import "custom-style" directive. The Rails Guide here recommends using #import (which is processed with SCSS/LESS) are over //=require (which is processed with Sprockets):
If you want to use multiple Sass files, you should generally use the Sass #import rule instead of these Sprockets directives. Using Sprockets directives all Sass files exist within their own scope, making variables or mixins only available within the document they were defined in.
This doesn't really answer your question, but is the only reason you are mixing sass and less to use twitter bootstrap? If you prefer to use just sass, there are some bootstrap gems where the authors convert the less to scss, like bootstrap-sass. Before I wasted too much time trying to juggle both in a project, I'd completely buy into one or the other, but that's just my opinion.

Resources