From 2a910335afd1cc2635d8ebb771a307f2b2859a24 Mon Sep 17 00:00:00 2001 From: Alex Ling Date: Fri, 24 Jul 2020 05:11:13 +0000 Subject: [PATCH] Easier to use `mango.css` helper method --- src/plugin/plugin.cr | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/plugin/plugin.cr b/src/plugin/plugin.cr index c3a1c32..b161c75 100644 --- a/src/plugin/plugin.cr +++ b/src/plugin/plugin.cr @@ -251,9 +251,14 @@ class Plugin selector = env.require_string 1 myhtml = Myhtml::Parser.new html - json = myhtml.css(selector).map(&.to_html).to_a.to_json + ary = myhtml.css(selector).map(&.to_html).to_a + + ary_idx = env.push_array + ary.each_with_index do |str, i| + env.push_string str + env.put_prop_index ary_idx, i.to_u32 + end - env.push_string json env.call_success end sbx.put_prop_string -2, "css"