class Template {

    public Template resolveBy(Resolver resolver, DeclaringComponent currentComponent) {
        String replaced = content.replace("${this@templateName}", templateNameWithoutBrackets());
        Matcher m = pattern.matcher(replaced);
        if (!m.find()) return withContent(replaced);

        StringBuffer result = new StringBuffer();
        do {
            doResolve(m, result, resolver, currentComponent);
        } while (m.find());
        m.appendTail(result);
        String content = result.toString();
        return withContent(content);
    }

      Template(String templateName, File source, Pattern pattern);

}