Skip to content

Instantly share code, notes, and snippets.

@mathewtrivett
Last active January 11, 2021 10:29
Show Gist options
  • Save mathewtrivett/3f78db92278746743e82186110083a84 to your computer and use it in GitHub Desktop.
Save mathewtrivett/3f78db92278746743e82186110083a84 to your computer and use it in GitHub Desktop.
Testing Print CSS - app/views/layouts/application.html.erb
<!DOCTYPE html>
<html>
<head>
<title>Testing Print CSS</title>
<%= csrf_meta_tags %>
<%= csp_meta_tag %>
<meta name="viewport" content="width=device-width, initial-scale=1">
<% if params[:medium] == 'print' %>
<!-- Load your print.css file with media attribute equal to screen -->
<%= stylesheet_packs_with_chunks_tag 'print', media: 'screen', 'data-turbolinks-track': 'reload', id: 'print_styles' %>
<% else %>
<!-- Load your print.css file with media attribute equal to print -->
<%= stylesheet_packs_with_chunks_tag 'print', media: 'print', 'data-turbolinks-track': 'reload', id: 'print_styles' %>
<!-- Load your other CSS files -->
<% end %>
<!-- THE REST OF YOUR HEAD CODE -->
</head>
<body>
<%= yield %>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment