{"id":3235,"date":"2011-03-10T20:34:46","date_gmt":"2011-03-10T15:04:46","guid":{"rendered":"http:\/\/www.tothenew.com\/blog\/?p=3235"},"modified":"2017-05-01T12:56:15","modified_gmt":"2017-05-01T07:26:15","slug":"a-simple-read-moreless-grails-tag","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/a-simple-read-moreless-grails-tag\/","title":{"rendered":"A simple Read more\/less grails tag"},"content":{"rendered":"<p>Hello world.. In a pretty recent project, I was a given a task to implement &#8220;read more&#8221; custom tag to implement &#8220;read more&#8221; functionality (a block of text followed by a read more link. Block of text expands and collapses on clicking of a link). I will be honest over here.I did a pretty bad job and implemented the tag in a quiet dirty way. Later I found some time to work on it and end up creating something way better than previous effort \ud83d\ude00<\/p>\n<h3><b><span style=\"text-decoration: underline;\">Read More\/Less tag<\/span><\/b><\/h3>\n<p>It is a pretty simple tag in which you pass a block of text and in return you get the text &#8220;read more\/less&#8221;-ified (Ok! I know thats bad :P). Anyways, now for this tag to work, Jquery is required.<\/p>\n<h3><b><span style=\"text-decoration: underline;\">Tag syntax<\/span><\/b><\/h3>\n<p>Just enclose the block of text inside the &#8220;readMore&#8221; tag and you are done.<\/p>\n<p>[java]<br \/>\n&amp;lt;ls:readMore&amp;gt;${myText}&amp;lt;\/ls:readMore&amp;gt;<br \/>\n[\/java]<\/p>\n<h3><b><span style=\"text-decoration: underline;\">Output<\/span><\/b><\/h3>\n<p><a href=\"\/blog\/wp-ttn-blog\/uploads\/2011\/03\/readMore_op_1.png\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-3242\" src=\"\/blog\/wp-ttn-blog\/uploads\/2011\/03\/readMore_op_1.png\" alt=\"\" width=\"320\" height=\"38\" \/><\/a><\/p>\n<p>After clicking the read more\/less&#8230;<br \/>\n<a href=\"\/blog\/wp-ttn-blog\/uploads\/2011\/03\/readMore_op_2.png\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-3245\" src=\"\/blog\/wp-ttn-blog\/uploads\/2011\/03\/readMore_op_2.png\" alt=\"\" width=\"320\" height=\"125\" \/><\/a><\/p>\n<p>This tag can be used to create multiple &#8220;read more&#8221;s like following:<br \/>\n<a href=\"\/blog\/wp-ttn-blog\/uploads\/2011\/03\/readMore_op_3.png\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-3250\" src=\"\/blog\/wp-ttn-blog\/uploads\/2011\/03\/readMore_op_3.png\" alt=\"\" width=\"320\" height=\"314\" \/><\/a><\/p>\n<p>I believe there is still room for improvement in tag and will try to bring in as much as possible . You can download the code from the following link and play around with it if required. Feel free to advice me on how can I improve the tag or you can come up with your own improvements. Ciao<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hello world.. In a pretty recent project, I was a given a task to implement &#8220;read more&#8221; custom tag to implement &#8220;read more&#8221; functionality (a block of text followed by a read more link. Block of text expands and collapses on clicking of a link). I will be honest over here.I did a pretty bad [&hellip;]<\/p>\n","protected":false},"author":34,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":2},"categories":[7],"tags":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/3235"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/34"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=3235"}],"version-history":[{"count":0,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/3235\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=3235"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=3235"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=3235"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}