You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Sinuhé (JIRA)" <ji...@apache.org> on 2017/01/09 14:37:58 UTC

[jira] [Comment Edited] (GROOVY-8038) Change BaseTemplate private methods to protected

    [ https://issues.apache.org/jira/browse/GROOVY-8038?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15811915#comment-15811915 ] 

Sinuhé edited comment on GROOVY-8038 at 1/9/17 2:37 PM:
--------------------------------------------------------

Yes, I can do that. In fact I am doing this right now, but I'm finding myself overriding most of the {{BaseTemplate}} public methods and cloning some private methods too. IMHO, current private methods are solving basic needs that any subclass should have access to.

Some examples of what I'm trying to do:
* Make a new method that, given a map, creates an {{<img>}} tag with some {{data-*}} attributes needed for responsive images. It would be great  to use {{writeAttribute/s}}.
* I need a richer (more methods) model and writer. Ideally, I would only override {{forkModel}} and {{createWriter}}, one or two lines of code per each. Now I have to copy code of {{writeTo}} and two {{layout}} methods, and still clone {{forkModel}} and {{createWriter}}.


was (Author: sinuhepop):
Yes, I can do that. In fact I am doing this right now, but I'm finding myself overriding most of the {{BaseTemplate}} public methods and cloning some private methods too. IMHO, current private methods are solving basic needs that any subclass should have access to.

Some examples of what I'm trying to do:
* Make a new method that, given a map, creates an {{<img>}} tag with some {{data-*}} attributes needed for responsive images. It would be great  to use {{writeAttribute/s}}.
* I need a richer (more methods) model and writer. Ideally, I would only override {{forkModel}} and {{createWriter}}, one or two lines of code per each. Now I have to copy code of {{writeTo}} and two {{layout}} methods.

> Change BaseTemplate private methods to protected
> ------------------------------------------------
>
>                 Key: GROOVY-8038
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8038
>             Project: Groovy
>          Issue Type: Improvement
>          Components: Templating
>    Affects Versions: 2.4.7
>            Reporter: Sinuhé
>            Priority: Minor
>
> *groovy.text.markup.BaseTemplate* is a good candidate for extending it with custom methods. The problem is that common methods such as *createWriter()*, *forkModel()*, *writeIndent()* should be accessible by extended class. For simplicity, I suggest to change all current private methods to protected. Fields should be accessible too.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)