Giter VIP home page Giter VIP logo

freemarker / fmpp Goto Github PK

View Code? Open in Web Editor NEW
81.0 81.0 24.0 6.58 MB

Command line and Ant tool for processing files with FreeMarker

Home Page: http://fmpp.sourceforge.net/

License: Other

Shell 0.37% HTML 25.47% JavaScript 0.05% C 0.04% CSS 0.80% Java 70.64% Logos 0.01% Batchfile 0.64% Yacc 0.01% C++ 0.01% FreeMarker 1.96% Roff 0.01% R 0.01% RPC 0.01% XSLT 0.01% Rich Text Format 0.01%

fmpp's People

Contributors

ddekany avatar jmerdich avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fmpp's Issues

Data parsed from JSON objects should not require a name

Parsing of a javascript object fails if a name isn't specified with it.

config.fmpp: (produces error)

sources:infile.orig.html
outputFile:outfile.html
data:{json(/root/fmpp_test_bug/esa_alert.json)}

config.good.fmpp: (this succeeds with name of vars and modified source file to use this)

sources:infile.mod.html
outputFile:outfile.html
data:{vars: json(/root/fmpp_test_bug/esa_alert.json)}

The error produced is:

Note: Using the config.fmpp in the working directory.
Failed!
Failed to apply the value of the "data" setting.

Caused by:
TDD error: Function doesn't evalute to a Map, but to fmpp.models.JSONObjectNode, so it can't be merged into the hash.
Error location: line 3, column 7 in /root/fmpp_test_bug/config.fmpp:
data:{json(/root/fmpp_test/esa_alert.json)}

This is using FMPP version 0.9.15.

I will send the assignee source files offline.

Upgrade to freemarker 2.3.25?

Is it possible to update this to the most recent version of freemarker?

I tried to build the project locally, so I could submit a diff, but could not get my environment setup.

Thanks,
Cory

XInclude and XML rendering

Hi,

I'm new to FMPP and I'm trying to have it render a single XML document to a very basic one-liner text file. Templating does work as expected, except regarding the XInclude feature: I can't make FMPP apply the transclusion. In the called template, browsing the DOM with pp.doc returns an xi:include element instead of the target one.

XInclude does work when used with static XML data sources (defined in the main config file), but not with dynamic XML rendering. I use the latest version. What did I forget ?

Config file

recommendedDefaults: 0.9.16
sourceRoot: /home/marin/fmpp/in
outputRoot: /home/marin/fmpp/out
dataRoot:   /home/marin/fmpp/data

modes : [
    ignore(/templates/)
]

data: {
    # Works fine: <xi:include> elements are processed.
    works: xml(music/works/bach/bwv622.xml, {'xincludeAware': true})
}

xmlRenderings: [
    {
        # Does NOT work: <xi:include> elements are returned as-is.
        ifDocumentElementIs: release
        template: templates/release.tags
        xincludeAware: true
        xmlns: {D: http://www.w3.org/1999/xhtml, xi: http://www.w3.org/2001/XInclude}
    }
]

Source XML file

<release xmlns="http://www.w3.org/1999/xhtml"
         xmlns:xi="http://www.w3.org/2001/XInclude">
	<title>My release</title>
	<performances>
		<performance>
			<work>
				<xi:include href="/home/marin/fmpp/data/music/works/bach/bwv622.xml" parse="xml"/>
			</work>
		</performance>
	</performances>
</release>

Template

<#ftl ns_prefixes={"D":"http://www.w3.org/1999/xhtml"}>
<@pp.renameOutputFile extension="txt" />
<#assign release = pp.doc.release>
<#list release.performances.performance.work.* as c>
- ${c?node_name}
</#list>

Output

- include

Instead of the the root element from "/home/marin/fmpp/data/music/works/bach/bwv622.xml".

does fmpp command line support stdout mode insteadof create file?

I tried fmpp like

fmpp  test/template/index.ftl   >  index.html

but got following result

Failed!
The "outputRoot" setting was not set. FMPP can't start working without that.

I think , the outputRoot must be a Optional arguments to help developer use stdout in other way . like text processing.

Just a suggestion.

Localized Lookup

Hello. First, thanks for maintaining this project!

Second, I'd like to apologize for bringing up something that was done Twelve years ago ๐Ÿ˜›

I'm interested in FreeMarker's Localized Lookup functionality. Can we turn this on?

Within the FMPP Engine.java file, line 301:

fmCfg.setLocalizedLookup(false);

I was wondering what the "confusing effects" referenced in the change log would be if I set that to true.

Thank you!

FMPP use old FTL syntax

It should be possible to configure freemarker to use the old #-less syntax.

However, to give users time to prepare for this change, in FreeMarker 2.1 and 2.2 the usage of # is optional, unless the programmer enables strict syntax mode in the FreeMarker configuration by calling setStrictSyntaxMode(true) on Configuration. In fact, we strongly recommend this to programmers. Starting from some later release this setting will be initially set to true. Also, you can specify if you want to use strict syntax or old syntax in the template files with the ftl directive.

How can I configure the fmpp preprocessor to use this old syntax with the Ant integration? Is there a setting or how can one call setStrictSyntaxMode(false)?

I am grateful for any assistance!

JSON data null does not get loaded as null but as JSONNode

For the following FM file

<#if value??>
    not null
<#else>
    is null
</#if>

I'm trying to render it using JSON data {"value": null}. My config is following

data: {"value":null}

When I run the command

$ ./fmpp test.ftl -C config -o output

the output is not null. Checking the code, I believe null gets wrapped to JSONNullNode (https://github.com/freemarker/fmpp/blob/master/src/main/java/fmpp/models/JSONNode.java#L89) as value?is_node returns true. If I test the same code directly in freemarker (using https://try.freemarker.apache.org/) it gets evaluated to is null.

Is this a bug or expected behaviour? Should I load JSON differently?

Fine-grained skipUnchanged: consider <#include and <#import

  1. fmpp can check if the produced contents is identical to the previous file. In that case fmpp can skip rewriting the destination file, thus saving time for the consumers. The next build steps could see that "no modification was performed", thus recompilation/repackaging is not required.
    This does not require <#include/<#import analysis and it will speed up builds that include fmpp steps.

  2. fmpp can compute the set of imported files and their timestamps when processing the template. Thus at the subsequent build, it could check the actual timestamps and reprocess the file if imported file is updated.

Of course both approaches would fail in face of templates that create/modify/delete files when they execute, however I believe it is sad fmpp can't handle the typical cases gracefully.

Not able to load example json from http://fmpp.sourceforge.net/dataloader.html#key_json

When I try to load json from http://fmpp.sourceforge.net/dataloader.html#key_json I get following error:

[ERROR] Failed to execute goal com.googlecode.fmpp-maven-plugin:fmpp-maven-plugin:1.1:generate (generate-mailboxes) on project mailboxes-configuration: Failed to apply the value of the "data" setting.
[ERROR] 
[ERROR] Caused by:
[ERROR] TDD error: Function doesn't evalute to a Map, but to fmpp.models.JSONArrayNode, so it can't be merged into the hash.
[ERROR] Error location: line 1, column 1:
[ERROR] json(../data/mailboxes-data.txt, UTF-8)
[ERROR] ^

Can anyone try to reproduce it?

Datamodel wrongly inserted with squareBracket

The templates i'm working on are written with square brackets.
In the configuration, I'm therefore configuring fmpp to use square brackets using this configuration item

tagSyntax : "squareBracket"

The template is correctly interpreted and converted.
The problem is when I want to inject datamodel using tdd file.
In such a case, the datamodel is inserted in the ftl template using <#assign> directives, with angle brackets, and the data is not interpreted as good freemarker directive.

My template

[#assign myDirective = 'title' /]
<h1>${myDirective}</h1>

Data model

dataObject = {
  "key1" : "string value"
};

Result

<#assign key1 = "string value"/>
<h1>title</h1>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.