All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.jknack.handlebars.Lambda Maven / Gradle / Ivy

The newest version!
/**
 * Copyright (c) 2012-2015 Edgar Espina
 *
 * This file is part of Handlebars.java.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.github.jknack.handlebars;

import java.io.IOException;

/**
 *  

* When the value is a callable object, such as a lambda, the object will be * invoked and passed the block of text. The text passed is the literal block, * unrendered. {{tags}} will not have been expanded - the lambda should do that * on its own. In this way you can implement filters or caching. *

*

* Template: *

* *
 *  {{#wrapped}}
 *  {{name}} is awesome.
 *  {{/wrapped}}
 *  
* * Hash: * *
 *  Map hash = ...
 *  hash.put("name", "Willy");
 *  hash.put("wrapped", new Lambda<String>() {
 *    public String apply(Scope scope, Template template) {
 *     return "" + template.apply(scope) + "";
 *    }
 *  });
 *  
*

* Output: *

* *
 *  Willy is awesome.
 *  
* * @author edgar.espina * @param The lambda context. * @param The lambda output. * * @deprecated com.github.jknack.handlebars package is deprecated and marked for removal in subsequent releases which will involve removal of the handlebars dependency in AEM. */ @Deprecated(since = "2024-07-10") public interface Lambda { /** * Apply the lambda. * * @param context The current context. * @param template The current template. * @return The resulting text. * @throws IOException If the resource cannot be loaded. */ O apply(C context, Template template) throws IOException; }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy