This functionality isn't really something I want to maintain... I think
it belongs as a separate project. And, in fact, it already is one ;).
Check out StaticMatic
(http://www.stephenbartholomew.co.uk/2007/5/24/staticmatic-new-release-now-on-rubyforge).
- Nathan
Ryan T Mulligan wrote:
> So maybe Rails is a little to big for some static project you are
> working on. If this is the case you should still use haml! Why?
> Because haml is great and saves tons of time. Here is the code I've
> written to help me out with this.
>
> Maybe someone will include something like haml_partial into the repos?
> Any thoughts?
>
> -Ryan Mulligan
>
> #RAKEFILE
> #Basically just put it in your static .haml directory then it will
> generate .html and .css files alongside these files in the same exact
> directory.
> require 'haml/engine'
> require 'sass/engine'
>
> task :default => [:web]
> task :web => [:haml,:sass]
>
> desc 'Compile haml templates to html'
> task :haml do
> dirs = Dir['**/*.haml']
> dirs.each do |f|
> File.open(f, 'r') do |fi|
> File.open(f.gsub('haml','html'),'w') do |d|
> d << Haml::Engine.new(fi.read).to_html
> end
> end
> end
> end
>
> desc 'Compile sass templates to css'
> task :sass do
> dirs = Dir['**/*.sass']
> dirs.each do |f|
> File.open(f, 'r') do |fi|
> File.open(f.gsub('sass','css'),'w') do |d|
> d << Sass::Engine.new(fi.read).to_css
> end
> end
> end
> end
>
>
> Here is a patch to the haml helpers to create haml_partial which lets
> you use other haml files as mini-partials. It doesn't support moving
> variables between them or anything. It's really just to dry up really
> static stuff.
>
> ===================================================================
> --- haml/helpers.rb (revision 518)
> +++ haml/helpers.rb (working copy)
> @@ -306,6 +306,20 @@
> result.to_s
> end
>
> + # Takes in a path to a .haml file which is then parsed inline for
> the current
> + # file.
> + #
> + # #Both of these yield same result
> + # =haml_partial('footer')
> + # =haml_partial('footer.haml')
> + def haml_partial(path)
> + # if we don't have the extension assume it is .haml
> + if File.extname(path).empty?
> + path += '.haml'
> + end
> + Haml::Engine.new(File.read(path)).to_html # I doubt this is the
> most efficient way to do this.
> + end
> +
> # Returns whether or not the current template is a Haml template.
> #
> # This function, unlike other Haml::Helpers functions,
>
>
> >
>
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---