StubbleOrg / Stubble

Trimmed down {{mustache}} templates in .NET
Other
399 stars 58 forks source link

I Need to set QR code by base64 #104

Closed drinkmuffin closed 4 years ago

drinkmuffin commented 4 years ago

HI

my html like this

qrCodeSrc set 'data:image/png;base64,...........'

but the result will be "" src is empty

what need i do?

Romanx commented 4 years ago

Hi there,

I'm not sure I can work out what is wrong from your sample. Can you provide a some reproduction code?

Thanks,

drinkmuffin commented 4 years ago

this template is "<!DOCTYPE html><html><head><meta charset="utf-8" /><title></title></head><body><div><img src="{{qrCodeSrc}}" /></div></body></html>"

the qrCodeSrc = "'data:image/png;base64,...........'"

after result will be "<img></img>"

i hope the image display by data-url(base64)

Romanx commented 4 years ago

Hi there,

Your example looks like it should work fine. Your code should look something like this

var stubble = new StubbleBuilder().Build();
var template = "<!DOCTYPE html><html><head><meta charset="utf-8" /><title></title></head><body><div><img src="{{qrCodeSrc}}" /></div></body></html>";

var output  = stubble.Render(template, new {
    qrCodeSrc = "data:image/png;base64,..........."
});
Romanx commented 4 years ago

I'm going to close this due to inactivity, hopefully the example helped.