Code Monkey home page Code Monkey logo

markupoc's Introduction

Markup for Objective C

Markup is simple and useful Markup Language。it was wirtten by Js and widely used in web. We alse can use it in Native code, So I rewrite it by Objective C . When you write iOS App , you can think about it .

Why use markup

1.markup is powerful,simple, and lightly

2.markup can combine temple and data,which help you merge data to view. you need not write hard code in your project.

3.lots of project use markup ,such as vue.js.

How to use

  1. import WKMarkup.h and WKMarkup.m
  2. use the interface.

-(NSString*) markupWithTemp:(id)tpContent withContent:(id)context withOption:(id)options;

NSDictionary *reDic = [NSJSONSerialization JSONObjectWithData:[self.dataContent dataUsingEncoding:NSUTF8StringEncoding] options:NSJSONReadingMutableLeaves error:&err];
    
value = [markup markupWithTemp:self.templateStr withContent:reDic withOption:nil];

example

value

template: Hi, {{name.first}}!

data: { name: { first: "John", last: "Doe" } }

output:"Hi, John!"

Array

template:Favorite color: {{colors.0}}
data:{ name: "John Doe", colors: ["Red", "Blue", "Green"] }
output:"Favorite color: Red"

Loops

  • template:<ul>{{brothers}}<li>{{.}}</li>{{/brothers}}</ul>
  • data:{ name: "John Doe", brothers: ["Jack", "Joe", "Jim"] }
  • output:<ul><li>Jack</li><li>Joe</li><li>Jim</li></ul>

Pipes

  • template:Name: {{name|upcase}}
  • data:{ name: "John Doe", alias: " J-Do ", phone: null, gender: "male", age: 33.33, vitals: [68, 162.5, "AB"], brothers: ["Jack", "Joe", "Jim"], sisters: [{name: "Jill"}, {name: "Jen"}], jiggy: true }
  • "Name: JOHN DOE"

Chaining pipes

  • template:Alias: {{alias|trim|downcase}}
  • data:{ name: "John Doe", alias: " J-Do ", phone: null, gender: "male", age: 33.33, vitals: [68, 162.5, "AB"], brothers: ["Jack", "Joe", "Jim"], sisters: [{name: "Jill"}, {name: "Jen"}], jiggy: true }
  • output:Alias: j-do

IF and IF/ELSE statements

  • template:{{if children|empty}} John has no kids. {{/if}}
  • data:{ name: "John Doe", alias: " J-Do ", phone: null, gender: "male", age: 33.33, vitals: [68, 162.5, "AB"], brothers: ["Jack", "Joe", "Jim"], sisters: [{name: "Jill"}, {name: "Jen"}], jiggy: true }
  • output:John has no kids.

markupoc's People

Contributors

alibaba-oss 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

Watchers

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

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.