This file contains hidden or 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
// skipped: 17 lines to define webpackBootstrap and __webpack_require__... | |
webpackBootstrap({ | |
0: function(module, exports, __webpack_require__) { | |
var helloTemplate = __webpack_require__(371); | |
console.log(helloTemplate({name: 'John'})); | |
}, | |
188: function(module, exports) { module.exports = Handlebars; }, | |
371: function(module, exports, __webpack_require__) { |
This file contains hidden or 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
<%@ taglib prefix="hbs" uri="http://www.hopwork.com/jsp/jstl/handlebars" %> | |
<%-- preferred form: all needed data are computed outside of the view and put into ${headerData} --%> | |
<hbs:render template="common/header" context="${headerData}"/> | |
<%-- sometimes, it's still useful to tweak the view independently of the data --%> | |
<hbs:render template="some/other/template"> | |
<hbs:contextProperty name="someCondition" value="true"/> | |
<hbs:contextProperty name="someConfigProperty" value="SOME_CONFIG_VALUE"/> | |
<hbs:contextProperty name="data" value="${someData}"/> |
This file contains hidden or 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
import lombok.Value; | |
@Value | |
public class ContextProperty { | |
String name; | |
Object value; | |
} |
This file contains hidden or 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
import com.github.jknack.handlebars.Helper; | |
import com.github.jknack.handlebars.Options; | |
import java.io.IOException; | |
import java.util.StringJoiner; | |
public class ConcatHelper implements Helper<Object> { | |
@Override | |
public Object apply(Object firstObjectToConcat, Options options) throws IOException { | |
StringJoiner joiner = new StringJoiner(""); |
This file contains hidden or 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
import com.github.jknack.handlebars.Handlebars; | |
import com.github.jknack.handlebars.cache.ConcurrentMapTemplateCache; | |
import com.github.jknack.handlebars.helper.*; | |
import com.github.jknack.handlebars.io.*; | |
import org.springframework.context.MessageSource; | |
import org.springframework.context.annotation.*; | |
import org.springframework.core.env.Environment; | |
import javax.inject.Inject; | |
import java.util.*; |
This file contains hidden or 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
import org.springframework.stereotype.Controller; | |
import org.springframework.web.bind.annotation.*; | |
import org.springframework.web.servlet.ModelAndView; | |
@Controller | |
public class HelloController { | |
@RequestMapping(path = "/hello", method = RequestMethod.GET) | |
public ModelAndView sayHelloTo(@RequestParam String name) { | |
return new ModelAndView("hello", "name", name); | |
} |
This file contains hidden or 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
import java.util.ArrayList; | |
import java.util.List; | |
import java.util.Optional; | |
import java.util.regex.Matcher; | |
import java.util.regex.Pattern; | |
import static java.util.Arrays.stream; | |
import static java.util.Collections.emptyList; | |
import static java.util.Collections.unmodifiableList; | |
import static java.util.Optional.ofNullable; |
This file contains hidden or 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
import lombok.Value; | |
// This code only works if compiling the code using javac's -parameters option (Java 8 only). | |
// With this option, Jackons can use the all-args constructor of our type. | |
// See https://gist.github.com/ndemengel/72f362bc31afe5fcaa0499af8f269651 for a more general solution. | |
@Value | |
public class EmailUpdated implements Event { | |
public static final String EXCHANGE_NAME = "email.updated.exchange"; |
This file contains hidden or 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
import lombok.*; | |
// The aim here is to have a type that looks like a value type, while still | |
// allowing Jackson to unmarshal our type from JSON. | |
// See https://gist.github.com/ndemengel/77a8ffbb929bc55e3d87809820c1c5a4 for a more elegant solution. | |
@AllArgsConstructor @Getter | |
@EqualsAndHashCode @ToString | |
@NoArgsConstructor(access = AccessLevel.PRIVATE) | |
public final class EmailUpdated implements Event<EmailUpdated> { |
This file contains hidden or 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
import lombok.Data; | |
@Data | |
public final class EmailUpdated { | |
private String accountId; | |
private String oldEmail; | |
private String newEmail; | |
public EmailUpdated(String accountId, String oldEmail, String newEmail) { | |
this.accountId = accountId; |