If you're on a Mac, you can use automator to process your file using a
command line action and then open the result in your browser. You can
even make the automator action the default for double clicking the
file.

chris

P.S. Would love to see a firefox extension to allow native reading of
haml AND sass.

On Aug 20, 3:00 pm, Paul Barry <[EMAIL PROTECTED]> wrote:
> Yeah, I'm specifically trying to avoid developers to require having
> any kind of server running to view the haml.
>
>     haml foo.haml > foo.html && open foo.html
>
> That's close, but still doesn't solve the open in finder or refresh
> problems.  Probably time to learn how to hack out a firefox extension.
>
> On Aug 20, 5:32 pm, Rhett Sutphin <[EMAIL PROTECTED]> wrote:
>
> > On Aug 20, 2008, at 4:23 PM, Paul Barry wrote:
>
> > > Does anyone have a tool yet that allows you to double click on a haml
> > > file and see it's render HTML content in a browser?  And for bonus
> > > points be able to edit the file, press refresh in the browser and see
> > > the updated HTML?
>
> > Almost.  There was a thread just a few days ago about viewing haml
> > directly in Apache:
>
> >http://groups.google.com/group/haml/browse_thread/thread/3a1d93760f33...
>
> > I use a ruby script that uses Webrick to serve all the haml and sass
> > files in a directory.  It's based on one by John Long I found at
> > Wiseheart Design (inline below).
>
> > Neither of these allow you to double click on the file to open it (you
> > have to know the URL to use, either served from Apache or Webrick),
> > but otherwise they have the properties you mention.
>
> > Rhett
>
> > ---- BEGIN SCRIPT -----
>
> > #!/usr/bin/env ruby
>
> > # Simple server that lets you automatically preview Haml outside of an
> > # application.  
> > Fromhttp://wiseheartdesign.com/2007/9/4/a-haml-server-for-web-designers/
>
> > require 'webrick'
> > require 'rubygems'
> > require 'haml'
> > require 'sass'
>
> > class AbstractHamlHandler < WEBrick::HTTPServlet::AbstractServlet
>
> >    def initialize(server, name)
> >      super
> >     [EMAIL PROTECTED] = name
> >    end
>
> >    def do_GET(req, res)
> >      begin
> >        data = open(@script_filename) {|io| io.read }
> >        res.body = parse(data)
> >        res['content-type'] = content_type
> >      rescue StandardError => ex
> >        raise
> >      rescue Exception => ex
> >       [EMAIL PROTECTED](ex)
> >        raise HTTPStatus::InternalServerError, ex.message
> >      end
> >    end
>
> >    alias do_POST do_GET
>
> >    private
>
> >    def parse(string)
> >      engine = engine_class.new(string,
> >        :attr_wrapper => '"',
> >        :filename => @script_filename
> >      )
> >      engine.render
> >    end
> > end
>
> > class HamlHandler < AbstractHamlHandler
> >    def content_type
> >      'text/html'
> >    end
>
> >    def engine_class
> >      Haml::Engine
> >    end
> > end
>
> > class SassHandler < AbstractHamlHandler
> >    def content_type
> >      'text/css'
> >    end
>
> >    def engine_class
> >      Sass::Engine
> >    end
> > end
>
> > WEBrick::HTTPServlet::FileHandler.add_handler("haml", HamlHandler)
> > WEBrick::HTTPServlet::FileHandler.add_handler("sass", SassHandler)
>
> > args = ARGV.join(' ')
> > args.gsub!(%r{^http://}, '')
> > args = args.split(/[ :]/).compact
>
> > server = WEBrick::HTTPServer.new(
> >    :Port => args.pop || 3000,
> >    :BindAddress => args.pop || '0.0.0.0',
> >    :DocumentRoot => Dir.pwd
> > )
>
> > trap("INT") { server.shutdown }
>
> > server.start
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Haml" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/haml?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to