MatijaL

MatijaL

How to use versioned file in my template?

Hello,

I have icons.svg file which contains svg symbols. In my template I use it like this with a verified route:

<svg>
   <use xlink:href={ ~p"/images/icons.svg#arrow" }></use>
</svg>

This line of code always calls for icons.svg file, but in production, this file gets versioned to something like icons-83f2a9a213b74424476fb160bbabaec8.svg?vsn=d.

How do I update verified routes to use versioned filename instead of base icons.svg?

Marked As Solved

psantos

psantos

Maybe Routes.static_path/2 would help.

<svg>
   <use xlink:href={static_path(@conn, "/images/icons.svg") <> "#arrow"}></use>
</svg>

In development static_path/2 will return icons.svg but in production it will return the path to the fingerprinted version.

Also Liked

LostKobrakai

LostKobrakai

Looking at the code it seems the #arrow part means matching with the cache manifest doesn’t work. Caching uses the path as supplied and doesn’t strip fragments from it, which therefore doesn’t match paths on the filesystem, which don’t have fragments to them.

MatijaL

MatijaL

Thank you for giving me the example.

Here’s the code with verified route which works.

<svg>
   <use xlink:href={ ~p"/images/icons.svg" <> "#arrow" }></use>
</svg>

Where Next?

Popular in Questions Top

albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
lk-geimfari
What is most correct way to open, read and parse JSON file with poison? For example if we have example.json file in root of some projec...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
vac
Hi, I'm quite new in Elixir and I'm trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and ...
New
Phillipp
Hey, I have a NanoPi-M3 and try to install Elixir on their Ubuntu image. I followed the Raspberry Pi installation instructions from the ...
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
chewm
Hi guys, nice to meet you to the whole forum, I’m new here, I’m trying to configure visual studio code for elixir, right now the intellis...
New
Codball
Mix format works fine if run from the cmd. I’ve followed this to facilitate the implementation into VSC which involves downloading an ext...
New

Other popular topics Top

Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
peerreynders
Manning 2016 Halloween weekend sale via Deal of the Day Friday, October 28 - Half off all MEAPs - code WM102816LT Saturday, October 29 ...
326 29600 154
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
lk-geimfari
What is most correct way to open, read and parse JSON file with poison? For example if we have example.json file in root of some projec...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 42633 214
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New

We're in Beta

About us Mission Statement