-
-
Notifications
You must be signed in to change notification settings - Fork 382
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
v4: Inline Partial Definitions fix #429
- Loading branch information
Showing
10 changed files
with
230 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
handlebars/src/main/java/com/github/jknack/handlebars/helper/InlineHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.github.jknack.handlebars.helper; | ||
|
||
import java.io.IOException; | ||
import java.util.Map; | ||
|
||
import com.github.jknack.handlebars.Context; | ||
import com.github.jknack.handlebars.Helper; | ||
import com.github.jknack.handlebars.Options; | ||
|
||
/** | ||
* Inline partials are implemented via helpers (not decorators like in handlebars.js). Decorators | ||
* are not supported in handlebars.java. | ||
* | ||
* <pre> | ||
* {{#*inline \"myPartial\"}}success{{/inline}}{{> myPartial}} | ||
* </pre> | ||
* | ||
* @author edgar | ||
* @since 4.0.0 | ||
*/ | ||
public class InlineHelper implements Helper<String> { | ||
|
||
/** | ||
* A singleton instance of this helper. | ||
*/ | ||
public static final Helper<String> INSTANCE = new InlineHelper(); | ||
|
||
@Override | ||
public CharSequence apply(final String path, final Options options) throws IOException { | ||
Map<String, Object> partials = options.data(Context.INLINE_PARTIALS); | ||
partials.put(path, options.fn); | ||
return null; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.