librelist archives

« back to archive

Newbie Nesta helper question

Newbie Nesta helper question

From:
Jake Subs
Date:
2012-02-08 @ 12:51
I'd like to implement Paul Irish's conditional class solution for
Internet Explorer:
http://paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/

Gianni Chiappetta has written a Rails/Padrino HAML helper:
http://gf3.ca/2011/02/12/conditional-html-tag-haml

I've created a new theme according to
http://nestacms.com/docs/design/creating-themes , and I've added the
helper to `app.rb`, where it says "# Add new helpers here."

I add the following to layout.haml

     !!! 5

    - conditional_html 'en-GB'

But I get this error message:
    NoMethodError at /
    undefined method `html_safe!' for #<String:0xa07a1c0>
    file: util.rb location: html_safe line: 451

I've tried replacing `haml_concat` and `capture` as per instructions
for Padrino but still no dice. Any ideas?

I'm a total newcomer to Nesta, Sinatra, Ruby etc. so probably
something *immensely* basic!!

Many thanks, Jake

Re: [nesta] Newbie Nesta helper question

From:
Graham Ashton
Date:
2012-02-08 @ 17:50
On 8 Feb 2012, at 12:51, Jake Subs wrote:

> Gianni Chiappetta has written a Rails/Padrino HAML helper:
> http://gf3.ca/2011/02/12/conditional-html-tag-haml

Hi Jake. That helper needs some Haml methods that clearly aren't loaded by
default in Sinatra.

I'm sure we could load them in, but while getting myself setup to 
reproduce the problem I scanned the comments on Gianni's blog post. I 
found this Gist which does the same thing, without needing the methods 
that aren't available to you:

https://gist.github.com/1506887

I'd use that; it's simpler and works without loading any more Haml code. 
Gianni's point about DRY is irrelevant in this context, as that gist 
doesn't violate DRY (which stands for Don't Repeat Yourself). I can see 
you'd need to repeat it if your site used multiple layouts, but I'd be 
tempted to just stick it in a partial template at that point.

> I've created a new theme according to
> http://nestacms.com/docs/design/creating-themes , and I've added the
> helper to `app.rb`, where it says "# Add new helpers here."

I think I need to rename a couple of the pages in the docs, and possibly 
update the language.

If you're only skinning one site and don't want to share/re-use the design
elsewhere, I'd recommend taking one of the two approaches outlined here:

http://nestacms.com/docs/design/editing-default-templates
http://nestacms.com/docs/design/custom-designs

The page you linked to was written with the intention that you'd only make
your own theme if you needed to re-use it, or wanted to share it with the 
community. There's no reason not to create a theme just for your own site,
it's just slightly more involved...

Cheers,
Graham

--
Graham Ashton
Founder, The Agile Planner
http://theagileplanner.com | @agileplanner | @grahamashton

Re: [nesta] Newbie Nesta helper question

From:
Jake Subs
Date:
2012-02-08 @ 19:42
On 8 February 2012 17:50, Graham Ashton <graham@effectif.com> wrote:
> I found this Gist which does the same thing, without needing the methods
that aren't available to you:
> https://gist.github.com/1506887

Brilliant, works a charm, thank you :)

> I'd use that; it's simpler and works without loading any more Haml code.
Gianni's point about DRY is irrelevant in this context, as that gist 
doesn't violate DRY

I guess the only quibble would be about repeating `lang="en"`. But I'm
not going to lose any sleep over it.

> The page you linked to was written with the intention that you'd only 
make your own theme if you needed to re-use it, or wanted to share it with
the community. There's no reason not to create a theme just for your own 
site, it's just slightly more involved...

It's good, I want to make it portable and standalone, and it's fairly
clear from the documentation that that's how it works.

I'm building my first responsive web design, using sass and
http://semantic.gs, so will make my humble creations public if you
like.

Thanks for your help, very much appreciated, Jake

Re: [nesta] Newbie Nesta helper question

From:
Graham Ashton
Date:
2012-02-08 @ 20:53
On 8 Feb 2012, at 19:42, Jake Subs <subs@growdigital.org> wrote:

> I'm building my first responsive web design, using sass and
> http://semantic.gs, so will make my humble creations public if you
> like.

Yes please! We need more themes, and I've been a bit too busy to convert 
the existing ones to a responsive design recently.

Let me know if you need a hand with anything...

Re: [nesta] Newbie Nesta helper question

From:
Jake Subs
Date:
2012-02-09 @ 17:20
On 8 February 2012 20:53, Graham Ashton <graham@effectif.com> wrote:
> Yes please! We need more themes, and I've been a bit too busy to convert
the existing ones to a responsive design recently.

Excellent. I've slapped a Creative Commons license on it, and I'll
bundle up a vanilla flavoured version as well.

Will take you up on the help offer, as I Know Nothing About Ruby!!

Re: [nesta] Newbie Nesta helper question

From:
Graham Ashton
Date:
2012-02-09 @ 18:15
On 9 Feb 2012, at 17:20, Jake Subs wrote:

> Excellent. I've slapped a Creative Commons license on it, and I'll
> bundle up a vanilla flavoured version as well.

Awesome.

> Will take you up on the help offer, as I Know Nothing About Ruby!!

Okay. If you get stuck on something that you think might be a quick fix 
you can normally find me in #nesta on freenode.

--
Graham Ashton
Founder, The Agile Planner
http://theagileplanner.com | @agileplanner | @grahamashton