Skip to content

Instantly share code, notes, and snippets.

@rmw
Last active December 20, 2015 15:39
Print CSS - creating non-semantic print classes Useful for links which auto get expanded into 'text (url)' which you may not want ... especially for email or if the link text is the actual url.
def print_link(text, url)
link_to(text, url, class: 'no-print') <<
content_tag('span', class: 'print-only') { text }
end
describe "#print_link" do
it "should render a link with text, url, and no-print class" do
helper.should_receive(:link_to).
with('yo', 'http://blah.com', class: 'no-print').
and_return("")
helper.print_link('yo', 'http://blah.com')
end
it "should render a span with print-only class and text" do
helper.print_link('yo', 'http://blah.com').should =~ /span class=\"print-only\">yo/
end
end
@include print-utilities;
// http://compass-style.org/reference/compass/utilities/print/
@import "compass/utilities/print";
@include print-utilities(screen);
.print_only {
display: block;
&span, &b, &i, &small, &strong, &em, &a, &img, &button, &input, &label, &select, &textarea {
display: inline;
}
}
.no_print {
display: none;
}
.print_only {
display: none;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment