Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use mustache (fork) #23

Open
microspino opened this issue Feb 10, 2012 · 4 comments
Open

use mustache (fork) #23

microspino opened this issue Feb 10, 2012 · 4 comments

Comments

@microspino
Copy link

I really like Bonsai and i would like to add mustache templates to it, although I know Tilt doesn't suport it. How do I have to proceed? Do I need to fork your project?. Do you think it's a bad idea? Is there anything against using it in parallel but separated from tilt. Sorry github and gem newbie here this will be the first fork for me, I don't know ethics or etiquette of doing it.

@benschwarz
Copy link
Owner

Hmm. InterestingBonsai used to use mustache in the beginning but it was removed from 'tilt'.
I recently saw a gem that re-added support for it. (https://github.com/Becojo/tilt-mustache)

So, I'd try installing the gem, then try requiring it in bonsai by adding a file called extensions.rb in the root directory of your bonsai site.
Then, you could require 'tilt-mustache'.

Just an idea, I haven't tried it but I'm reasonably sure it would work.

Good luck!

On 11/02/2012, at 10:33 AM, Daniele Spinosa wrote:

I really like Bonsai and i would like to add mustache templates to it, although I know Tilt doesn't suport it. How do I have to proceed? Do I need to fork your project (sorry github and gem nnewbie here).


Reply to this email directly or view it on GitHub:
#23

@benschwarz
Copy link
Owner

Any luck, Daniele?

On 11/02/2012, at 10:33 AM, Daniele Spinosareply@reply.github.com wrote:

I really like Bonsai and i would like to add mustache templates to it, although I know Tilt doesn't suport it. How do I have to proceed? Do I need to fork your project (sorry github and gem nnewbie here).


Reply to this email directly or view it on GitHub:
#23

@microspino
Copy link
Author

Hello, sorry for the lack feedback. In a few word: "it works with some glitches".
Here is the commented content of my extensions.rb.

require 'tilt-mustache'

module Bonsai
  class Navigation
    # without this i can't generate the main navigation links
    def self.tree
      pages = Page.all(Page.path, "*").select{|p| !p.floating? }.sort_by{|p| p.disk_path }
      pages.map {|p| {:permalink => p.permalink, :name => p.name}}
    end
  end

  class Page
    # without this i can't generate Fig, Maple, Magic, links under varieties
    def children
      pages = Page.all(File.dirname(disk_path), "*").delete_if{|p| p.floating? }
      pages.map {|p| {:permalink => p.permalink, :name => p.name}}
    end
  end
end

If I don't reopen Navigation and Page classes I get: undefined method 'permalink' for #.
There are, probably, better ways to fix my issues but i'm not a strong ruby coder...As of today, i promise you to improve :)
I've used only the default.mustache and products.mustache templates until now. Here are they:

default.mustache

<!DOCTYPE html>
<html lang="en">
  {{>templates/shared/head}}
  <body id="{{slug}}">
    <section id="wrapper">
      {{>templates/shared/header}}

      <article>
        <h2>{{headline}}</h2>
        <section role="main">
          {{{body}}}
        </section>
      </article>

      {{>templates/shared/footer}}
    </section>
    {{>templates/shared/analytics}}
  </body>
</html>

products.mustache

<!DOCTYPE html>
<html lang="en">
  {{>templates/shared/head}}
  <body id="{{slug}}">
    <section id="wrapper">
      {{>templates/shared/header}}

      <article>
        <h2>{{headline}}</h2>
        <section role="main">
          {{body}}
        </section>
      </article>

      <nav id="sub-navigation">
        <ol>
          {{#children}}
            <li><a href="{{permalink}}">{{name}}</a></li>
          {{/children}}
        </ol>
      </nav>

      {{>templates/shared/footer}}
    </section>

  </body>
  {{>templates/shared/analytics}}
</html>

Please let me know if could help more or improve this.

@benschwarz
Copy link
Owner

Hey,

That's really excellent Daniele, well done!

If I get time I'll have a go myself.

Cheers,

Ben

On Thursday, 15 March 2012 at 8:58 PM, Daniele Spinosa wrote:

Hello, sorry for the lack feedback. In a few word: "it works with some glitches".
Here is the commented content of my extensions.rb.

require 'tilt-mustache'

module Bonsai
class Navigation

without this i can't generate the main navigation links

def self.tree
pages = Page.all(Page.path, "*").select{|p| !p.floating? }.sort_by{|p| p.disk_path }
pages.map {|p| {:permalink => p.permalink, :name => p.name}}
end
end
class Page

without this i can't generate Fig, Maple, Magic, links under varieties

def children
pages = Page.all(File.dirname(disk_path), "*").delete_if{|p| p.floating? }
pages.map {|p| {:permalink => p.permalink, :name => p.name}}
end
end
end

If I don't reopen Navigation and Page classes I get: undefined method 'permalink' for #.
There are, probably, better ways to fix my issues but i'm not a strong ruby coder...As of today, i promise you to improve :)
I've used only the default.mustache and products.mustache templates until now. Here are they:

default.mustache

{{>templates/shared/head}}
{{>templates/shared/header}}

{{headline}}

{{{body}}}
{{>templates/shared/footer}}
{{>templates/shared/analytics}}

products.mustache

{{>templates/shared/head}}
{{>templates/shared/header}}

{{headline}}

{{body}}
    {{#children}}
  1. {{name}}
  2. {{/children}}
{{>templates/shared/footer}}
{{>templates/shared/analytics}} Please let me know if could help more or improve this.

Reply to this email directly or view it on GitHub:
#23 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants