com.github.mustachejava.Mustache.invert()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(6.1k)|赞(0)|评价(0)|浏览(145)

本文整理了Java中com.github.mustachejava.Mustache.invert()方法的一些代码示例,展示了Mustache.invert()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Mustache.invert()方法的具体详情如下:
包路径:com.github.mustachejava.Mustache
类名称:Mustache
方法名:invert

Mustache.invert介绍

[英]Invert this mustache given output text.
[中]在给定输出文本的情况下反转此胡子。

代码示例

代码示例来源:origin: spullara/mustache.java

@Override
 public Node invert(Node node, String text, AtomicInteger position) {
  int start = position.get();
  List<Node> nodes = new ArrayList<>();
  Node invert;
  while ((invert = mustache.invert(new Node(), text, position)) != null) {
   nodes.add(invert);
  }
  node.put(name, list(nodes));
  return matchAppended(node, text, position, start);
 }
}

代码示例来源:origin: spullara/mustache.java

@Test
public void testCollectPoints() throws Exception {
 MustacheFactory dmf = new DefaultMustacheFactory();
 Mustache compile = dmf.compile(new StringReader("{{#page}}This is a {{test}}{{/page}}"),
     UUID.randomUUID().toString());
 Node node = compile.invert("This is a good day");
 assertNotNull(node);
}

代码示例来源:origin: spullara/mustache.java

@Test
 public void testNoNode() throws Exception {
  MustacheFactory dmf = new DefaultMustacheFactory();
  Mustache compile = dmf.compile(new StringReader("Using cluster file [^\\n]+\nHello World"),
    UUID.randomUUID().toString());
  Node node = compile.invert("Using cluster file `/etc/foundationdb/fdb.cluster'.\nHello World");
  assertNotNull(node);
 }
}

代码示例来源:origin: spullara/mustache.java

@Test
public void testToJson4() throws IOException {
 DefaultMustacheFactory dmf = new DefaultMustacheFactory();
 Mustache compile = dmf.compile("fdbcli2.mustache");
 Path file = getPath("src/test/resources/fdbcli3.txt");
 String txt = new String(Files.readAllBytes(file), "UTF-8");
 System.out.println("Input text:[");
 System.out.print(txt);
 System.out.println("]");
 Node invert = compile.invert(txt);
 output(invert);
}

代码示例来源:origin: spullara/mustache.java

@Test
public void testParser() throws IOException {
 DefaultMustacheFactory dmf = new DefaultMustacheFactory();
 Mustache compile = dmf.compile("fdbcli.mustache");
 Path file = getPath("src/test/resources/fdbcli.txt");
 String txt = new String(Files.readAllBytes(file), "UTF-8");
 Node invert = compile.invert(txt);
 System.out.println(invert);
}

代码示例来源:origin: spullara/mustache.java

@Test
public void testToJson5() throws IOException {
 DefaultMustacheFactory dmf = new DefaultMustacheFactory();
 Mustache compile = dmf.compile("fdbcli3.mustache");
 Path file = getPath("src/test/resources/fdbcli.txt");
 String txt = new String(Files.readAllBytes(file), "UTF-8");
 Node invert = compile.invert(txt);
 output(invert);
}

代码示例来源:origin: spullara/mustache.java

@Test
public void testToJson() throws IOException {
 DefaultMustacheFactory dmf = new DefaultMustacheFactory();
 Mustache compile = dmf.compile("fdbcli.mustache");
 Path file = getPath("src/test/resources/fdbcli.txt");
 String txt = new String(Files.readAllBytes(file), "UTF-8");
 Node invert = compile.invert(txt);
 output(invert);
}

代码示例来源:origin: spullara/mustache.java

@Test
public void testToJson3() throws IOException {
 DefaultMustacheFactory dmf = new DefaultMustacheFactory();
 Mustache compile = dmf.compile("psauxwww.mustache");
 Path file = getPath("src/test/resources/psauxwww.txt");
 String txt = new String(Files.readAllBytes(file), "UTF-8");
 Node invert = compile.invert(txt);
 output(invert);
}

代码示例来源:origin: spullara/mustache.java

@Test
public void testDiskstats() throws IOException {
 DefaultMustacheFactory dmf = new DefaultMustacheFactory();
 Mustache m = dmf.compile(new StringReader("{{#disk}}\n" +
     "\\s+[0-9]+\\s+[0-9]+\\s+{{tag_device}} {{reads}} {{reads_merged}} {{sectors_read}} {{read_time}} {{writes}} {{writes_merged}} {{sectors_written}} {{write_time}} {{ios}} {{io_time}} {{weighted_io_time}}\n" +
     "{{/disk}}"), "diskstats");
 String txt = "  220   100 xvdb 3140 43 23896 216 57698654 45893891 1261011016 12232816 0 10994276 12222124\n" +
     "  220   100  xvdk 2417241 93 19338786 1287328 284969078 116717514 10144866416 1520589288 0 329180460 1521686240\n";
 Node invert = m.invert(txt);
 output(invert);
}

代码示例来源:origin: spullara/mustache.java

@Test
public void testToJson2() throws IOException {
 DefaultMustacheFactory dmf = new DefaultMustacheFactory();
 Mustache compile = dmf.compile("fdbcli2.mustache");
 Path file = getPath("src/test/resources/fdbcli2.txt");
 String txt = new String(Files.readAllBytes(file), "UTF-8");
 Node invert = compile.invert(txt);
 output(invert);
}

代码示例来源:origin: spullara/mustache.java

@Test
public void testSimple() throws IOException {
 DefaultMustacheFactory dmf = new DefaultMustacheFactory();
 Mustache test = dmf.compile(new StringReader("test {{value}} test"), "test");
 Node invert = test.invert("test value test");
 Node node = new Node();
 node.put("value", value("value"));
 assertEquals(node, invert);
}

代码示例来源:origin: spullara/mustache.java

@Test
public void testIterable() throws IOException {
 DefaultMustacheFactory dmf = new DefaultMustacheFactory();
 Mustache test = dmf.compile(new StringReader("{{#values}}\ntest: {{value}}\n{{/values}}"), "test");
 Node invert = test.invert("test: sam\ntest: fred\n");
 Node node = new Node();
 Node sam = new Node();
 sam.put("value", value("sam"));
 Node fred = new Node();
 fred.put("value", value("fred"));
 node.put("values", list(asList(sam, fred)));
 assertEquals(node, invert);
 StringWriter sw = new StringWriter();
 test.execute(sw, invert).close();
 System.out.println(sw);
}

代码示例来源:origin: com.github.spullara.mustache.java/compiler

@Override
 public Node invert(Node node, String text, AtomicInteger position) {
  int start = position.get();
  List<Node> nodes = new ArrayList<>();
  Node invert;
  while ((invert = mustache.invert(new Node(), text, position)) != null) {
   nodes.add(invert);
  }
  node.put(name, list(nodes));
  return matchAppended(node, text, position, start);
 }
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.mustache-compiler

@Override
 public Node invert(Node node, String text, AtomicInteger position) {
  int start = position.get();
  List<Node> nodes = new ArrayList<>();
  Node invert;
  while ((invert = mustache.invert(new Node(), text, position)) != null) {
   nodes.add(invert);
  }
  node.put(name, list(nodes));
  return matchAppended(node, text, position, start);
 }
}

相关文章