Relative stylesheet and javascript links.

50 vistas
Ir al primer mensaje no leído

Jake

no leída,
22 mar 2012, 2:35:49 p.m.22/3/12
para Serve Users
Perhaps this isn't a Serve question, I really don't know. I'm new to
the world of Rails. Anyway. I have a site that works great using the
Serve server but when exported the CSS and JavaScript links contain
'/' at the beginning. The client won't be running these files from the
web root so I need a way to remove that '/' prefix so the HTML will
treat it as relative. I'm using stylesheet_link_tag and
javascript_include_tag to generate the HTML. Is there a config or
something I set to have these generate relative links?

Thanks,

Jake

Jess Brown

no leída,
22 mar 2012, 4:30:28 p.m.22/3/12
para serve...@googlegroups.com
Hi Jake,

You could do something like this (if using erb):

<% @base_url = "/" if ENV['RACK_ENV'] == "development" %>
<base href="<%= @base_url %>" />
<link href="stylesheets/screen.css" media="screen, projection" rel="stylesheet" type="text/css" />


Jess




--
Jess Brown
Brown Web Design

Jake

no leída,
22 mar 2012, 6:27:54 p.m.22/3/12
para Serve Users
Oh, that looks like a good workaround. Thanks for the advice.

Jake
> @BrownWebDesign <http://twitter.com/brownwebdesign>
>
> Let's chat!  Schedule a phone call <http://brownwebdesign.com/book>

Chris Lee

no leída,
31 jul 2013, 10:20:22 p.m.31/7/13
para serve...@googlegroups.com,avera...@gmail.com
Can you do the same with haml?

Jess Brown

no leída,
31 jul 2013, 11:01:19 p.m.31/7/13
para serve...@googlegroups.com,avera...@gmail.com
I wouldn't see why not.  You'd just need to convert the erb tags to haml...something like this:

- @base_url = "/" if ENV['RACK_ENV'] == "development"
%base{:href => @base_url}
%link{:href => "stylesheets/screen.css", :media => "screen, projection", :rel => "stylesheet", :type => "text/css"}


Jess Brown
Brown Web Design

Let's chat!  Schedule a phone call
--
--
Serve Users Group
Mailing List: http://groups.google.com/group/serve-users/
Project: http://github.com/jlong/serve/
 
---
You received this message because you are subscribed to the Google Groups "Serve Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to serve-users...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Responder a todos
Responder al autor
Reenviar
0 mensajes nuevos