I'm working on a PHP project in-which I need to convert a .slim (http://slim-lang.com/) file to regular HTML.
Unfortunately, it seems the only way of doing this is through using Ruby as I can't find any PHP parsers for slim.
However, I'm totally new to ruby and have never even used it before. Anyways, I'm going to have to execute a .rb file from PHP to do the conversion.
However, I'm having trouble setting up ruby to run properly (I believe).
I setup a folder (slim) with the following:
Gemfile
source 'https://rubygems.org'
gem "listen"
gem "slim"
gem "sass"
Gemfile.lock
GEM
remote: https://rubygems.org/
specs:
ffi (1.9.0)
listen (1.3.0)
rb-fsevent (>= 0.9.3)
rb-inotify (>= 0.9)
rb-kqueue (>= 0.2)
rb-fsevent (0.9.3)
rb-inotify (0.9.1)
ffi (>= 0.5.0)
rb-kqueue (0.2.0)
ffi (>= 0.5.0)
sass (3.2.10)
slim (2.0.1)
temple (~> 0.6.6)
tilt (>= 1.3.3, < 2.1)
temple (0.6.6)
tilt (1.4.1)
PLATFORMS
ruby
DEPENDENCIES
listen
sass
slim
main.rb
require 'listen'
require 'slim'
# if source folder specified
if ARGV[0]
Listen.to!(ARGV[0], :filter => /\.slim$/) do |modified, added|
modified.each do |modified_file|
system("slimrb --pretty #{modified_file} > #{modified_file.gsub('.slim','')}.html --trace")
end
end
end
So from what I understand, this should get any file with a .slim extension and convert it to .html
Then in my PHP I've got:
<?php
$pathToRB = "http://example.com/path/to/ruby/file/main.rb";
exec($pathToRB);
?>
Unfortunately, it doesn't do anything though. I'm pretty sure this has something to do with having ruby running on the server or something, but like I said, I'm totally new to it and not sure how to get it up and running.
Any help is much appreciated.
systemfunction or similar?