html-loader icon indicating copy to clipboard operation
html-loader copied to clipboard

README documentation - first example - image.png needs to be image.jpg

Open wittibs opened this issue 10 years ago • 6 comments

In the first example, for file.html: <img src="image.png" data-src="image2x.png" > When it should be <img src="image.jpg" data-src="image2x.png" > As a beginner to understanding loaders, this slight typo really threw me off. :)

wittibs avatar Aug 18 '16 20:08 wittibs

Hi, seems to be my bad here, but can you explain little more detailed what threw off please :)

michael-ciniawsky avatar Aug 19 '16 16:08 michael-ciniawsky

From the README doc:

<!-- file.html -->
<img src="image.png" data-src="image2x.png" >

Notice the src attribute points to image.png. I believe it should point to image.jpg because ... In the proceeding example:

require("html!./file.html");

// => '<img src="http://cdn.example.com/49eba9f/a992ca.jpg"
//         data-src="image2x.png">'

The src attribute is updated accordingly, and it has a jpg extension. That's what threw me off, because originally it had a png extension.

wittibs avatar Aug 21 '16 23:08 wittibs

kk 👍 i will make the examples consistent

michael-ciniawsky avatar Aug 22 '16 01:08 michael-ciniawsky

Hi,

I believe that only the compiled example should be changed since after this instance in the code it clearly always references png extension with the same hash (a992ca).

<!-- file.html -->
<img src="image.png" data-src="image2x.png" >
require("html!./file.html");

// => '<img src="http://cdn.example.com/49eba9f/a992ca.jpg" /* Error is here */
//         data-src="image2x.png">'
require("html?attrs=img:data-src!./file.html");

// => '<img src="image.png" data-src="data:image/png;base64,..." >'
require("html?attrs=img:src img:data-src!./file.html");
require("html?attrs[]=img:src&attrs[]=img:data-src!./file.html");

// => '<img  src="http://cdn.example.com/49eba9f/a992ca.png"        
//           data-src="data:image/png;base64,..." >'

I've made the changes in #86 if that's ok with you @michael-ciniawsky.

andreicek avatar Sep 07 '16 07:09 andreicek

Pulled it in, LGTM, let me know if any others changes.

hemanth avatar Sep 07 '16 08:09 hemanth

@andreicek thx 👍

michael-ciniawsky avatar Sep 08 '16 12:09 michael-ciniawsky