@@ -0,0 +1,2292 @@
+/*%0A * Copyright (c) 2016 Konstantin Lepa %3Ckonstantin+ukase@lepabox.net%3E%0A *%0A * This file is part of Ukase.%0A *%0A *  Ukase is free software: you can redistribute it and/or modify%0A *  it under the terms of the GNU Affero General Public License as%0A *  published by the Free Software Foundation, either version 3 of the%0A *  License, or (at your option) any later version.%0A *%0A *   This program is distributed in the hope that it will be useful,%0A *  but WITHOUT ANY WARRANTY; without even the implied warranty of%0A *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the%0A *  GNU Affero General Public License for more details.%0A *%0A *  You should have received a copy of the GNU Affero General Public License%0A *  along with this program. If not, see %3Chttp://www.gnu.org/licenses/%3E.%0A */%0A%0Apackage com.github.ukase.toolkit.helpers;%0A%0Aimport com.github.jknack.handlebars.Options;%0Aimport org.apache.commons.lang3.StringUtils;%0Aimport org.springframework.stereotype.Component;%0A%0Aimport java.io.IOException;%0Aimport java.util.Map;%0A%0A@Component%0Apublic class SetVariableHelper extends AbstractHelper%3CObject%3E %7B%0A    private static final String HELPER_NAME = %22set_var%22;%0A%0A    public SetVariableHelper() %7B%0A        super(HELPER_NAME);%0A    %7D%0A%0A    @Override%0A    public CharSequence apply(Object context, Options options) throws IOException %7B%0A        CharSequence blockValue = StringUtils.trimToEmpty(options.fn().toString());%0A        if (options.isFalsy(blockValue)) %7B%0A            setVariable(options, context);%0A        %7D else %7B%0A            setVariable(options, blockValue);%0A        %7D%0A        return %22%22;%0A    %7D%0A%0A    private void setVariable(Options options, Object value) throws IOException %7B%0A        String name = getVariableName(options);%0A        Map%3CString, Object%3E currentContext = getContext(options);%0A        if (currentContext == null) %7B%0A            return;%0A        %7D%0A        currentContext.put(name, value);%0A    %7D%0A%0A    private String getVariableName(Options options) %7B%0A        return options.hash(%22name%22);%0A    %7D%0A%0A    @SuppressWarnings(%22unchecked%22)%0A    private Map%3CString, Object%3E getContext(Options options) %7B%0A        Object possibleContext = options.context.model();%0A        if (possibleContext instanceof Map) %7B%0A            return (Map%3CString, Object%3E)possibleContext;%0A        %7D%0A        return null;%0A    %7D%0A%7D%0A

Add set_var helper