« lib/WWW/Shopify/Liquid/Dialect/Web/Tag/EscapeJS.pm
↑ Summary
lib/WWW/Shopify/Liquid/Dialect/Web/Tag/Tablerow.pm »
| 1 | #!/usr/bin/perl | ||
| 2 | use strict; | ||
| 3 | use warnings; | ||
| 4 | |||
| 5 | package WWW::Shopify::Liquid::Dialect::Web::Tag::JavascriptString; | ||
| 6 | use base 'WWW::Shopify::Liquid::Tag::Enclosing'; | ||
| 7 | |||
| 8 | sub min_arguments { 0; } | ||
| 9 | sub max_arguments { 0; } | ||
| 10 | |||
| 11 | sub operate { | ||
| 12 | my ($self, $hash, $contents) = @_; | ||
| 13 | $contents =~ s/\n/\\n/g; | ||
| 14 | $contents =~ s/"/\\"/g; | ||
| 15 | $contents =~ s/{/" + /g; | ||
| 16 | $contents =~ s/}/ + "/g; | ||
| 17 | return "\"$contents\""; | ||
| 18 | } | ||
| 19 | |||
| 20 | |||
| 21 | |||
| 22 | 1; |